Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MostafaMollaali
dynamic
Commits
dbb67762
Commit
dbb67762
authored
5 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[App] parseMedia; Split conversion and insertion.
parent
b0d7f8b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Applications/ApplicationsLib/ProjectData.cpp
+30
-24
30 additions, 24 deletions
Applications/ApplicationsLib/ProjectData.cpp
with
30 additions
and
24 deletions
Applications/ApplicationsLib/ProjectData.cpp
+
30
−
24
View file @
dbb67762
...
...
@@ -454,38 +454,44 @@ void ProjectData::parseMedia(
remove_if
(
begin
(
material_id_string
),
end
(
material_id_string
),
[](
unsigned
char
const
c
)
{
return
std
::
isspace
(
c
);
}),
end
(
material_id_string
));
auto
const
material_ids
=
BaseLib
::
splitString
(
material_id_string
,
','
);
int
const
first_material_id
=
std
::
stoi
(
material_ids
.
front
());
for
(
auto
const
&
m_id
:
material_ids
)
auto
const
material_ids_strings
=
BaseLib
::
splitString
(
material_id_string
,
','
);
// Convert strings to ints;
std
::
vector
<
int
>
material_ids
;
std
::
transform
(
begin
(
material_ids_strings
),
end
(
material_ids_strings
),
std
::
back_inserter
(
material_ids
),
[](
std
::
string
const
&
m_id
)
{
if
(
auto
const
it
=
std
::
find_if_not
(
begin
(
m_id
),
end
(
m_id
),
[](
unsigned
char
const
c
)
{
return
std
::
isdigit
(
c
);
});
it
!=
end
(
m_id
))
{
OGS_FATAL
(
"Could not parse material ID's from '%s'. Please "
"separate multiple material ID's by comma only. "
"Invalid character: '%c'"
,
m_id
.
c_str
(),
*
it
);
}
return
std
::
stoi
(
m_id
);
});
for
(
auto
const
&
id
:
material_ids
)
{
if
(
auto
const
it
=
std
::
find_if_not
(
begin
(
m_id
),
end
(
m_id
),
[](
unsigned
char
const
c
)
{
return
std
::
isdigit
(
c
);
});
it
!=
end
(
m_id
))
{
OGS_FATAL
(
"Could not parse material ID's from '%s'. Please separate "
"multiple material ID's by comma only. Invalid character: "
"'%c'"
,
material_id_string
.
c_str
(),
*
it
);
}
int
const
material_id
=
std
::
stoi
(
m_id
);
if
(
_media
.
find
(
material_id
)
!=
end
(
_media
))
if
(
_media
.
find
(
id
)
!=
end
(
_media
))
{
OGS_FATAL
(
"Multiple media were specified for the same material id "
"'%
s
'. "
"'%
d
'. "
"Keep in mind, that if no material id is specified, it is "
"assumed to be 0 by default."
,
m_id
.
c_str
()
);
id
);
}
_media
[
material_id
]
=
(
material_id
==
first_
material_id
)
?
MaterialPropertyLib
::
createMedium
(
medium_config
,
_parameters
)
:
_media
[
first_
material_id
];
_media
[
id
]
=
(
id
==
material_id
s
[
0
]
)
?
MaterialPropertyLib
::
createMedium
(
medium_config
,
_parameters
)
:
_media
[
material_id
s
[
0
]
];
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment