Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Julien Cabieces
otb
Commits
92f976f9
Commit
92f976f9
authored
9 years ago
by
Rashad Kanavath
Browse files
Options
Downloads
Patches
Plain Diff
use boost::range_iterator in SplitStringToSingleKeyValue
parent
4666e7a1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Adapters/BoostAdapters/include/otbStringUtils.h
+19
-22
19 additions, 22 deletions
Modules/Adapters/BoostAdapters/include/otbStringUtils.h
with
19 additions
and
22 deletions
Modules/Adapters/BoostAdapters/include/otbStringUtils.h
+
19
−
22
View file @
92f976f9
...
@@ -81,10 +81,9 @@ ConvertStringToVector(std::string const &str, T& ret, std::string const& errmsg,
...
@@ -81,10 +81,9 @@ ConvertStringToVector(std::string const &str, T& ret, std::string const& errmsg,
* string. default delimitter is '='. If the string does not have a delimitter
* string. default delimitter is '='. If the string does not have a delimitter
* the key is set to input string and value is set to defValue.
* the key is set to input string and value is set to defValue.
* \param[in] str input string
* \param[in] str input string
* \param key An std::string reference where key will be stored
* \param key[out] An std::string reference where key will be stored
* \param value a reference of \cT where value will be stored
* \param value[out] a reference of \cT where value will be stored
* \param defValue a default value if there is no delimitter fo
* \param defValue[in] a default value if there is no delimitter fo
* \param doTrim check to perform boost::trim() ob key and values. Default is true.
* \param[in] errmsg a msg complement used to build the error message to
* \param[in] errmsg a msg complement used to build the error message to
be shown if there is \c lexical_cast exception. See \cotb:Utils::LexicalCast().
be shown if there is \c lexical_cast exception. See \cotb:Utils::LexicalCast().
* \param delims delimitter characters (space is default)
* \param delims delimitter characters (space is default)
...
@@ -98,32 +97,30 @@ cannot be converted into a valid \c T instance.
...
@@ -98,32 +97,30 @@ cannot be converted into a valid \c T instance.
template
<
typename
T
>
template
<
typename
T
>
void
SplitStringToSingleKeyValue
(
const
std
::
string
&
str
,
void
SplitStringToSingleKeyValue
(
const
std
::
string
&
str
,
std
::
string
&
key
,
T
&
value
,
const
T
&
defValue
,
std
::
string
&
key
,
T
&
value
,
const
T
&
defValue
,
std
::
string
const
&
errmsg
,
const
std
::
string
delims
=
"="
,
bool
doTrim
=
true
)
std
::
string
const
&
errmsg
,
const
std
::
string
delims
=
"="
)
{
{
std
::
size_t
pos
=
str
.
find
(
delims
);
if
(
pos
==
std
::
string
::
npos
)
{
key
=
str
;
value
=
defValue
;
}
key
=
str
.
substr
(
0
,
pos
);
std
::
string
value_
=
str
.
substr
(
pos
+
delims
.
size
(),
str
.
size
()
-
1
)
;
typedef
std
::
list
<
boost
::
iterator_range
<
std
::
string
::
const_iterator
>
>
ListType
;
//do optional trim
ListType
splitted
;
if
(
doTrim
)
{
boost
::
split
(
splitted
,
str
,
boost
::
is_any_of
(
delims
),
boost
::
token_compress_on
);
boost
::
trim_left
(
key
);
boost
::
trim_right
(
value_
);
}
if
(
typeid
(
value
)
!=
typeid
(
key
))
typename
ListType
::
iterator
it
=
splitted
.
begin
();
key
.
assign
((
*
it
).
begin
(),
(
*
it
).
end
());
boost
::
trim
(
key
);
++
it
;
if
(
it
!=
splitted
.
end
())
{
{
value
=
LexicalCast
<
T
>
(
value_
,
errmsg
);
const
std
::
string
v
=
std
::
string
((
*
it
).
begin
(),
(
*
it
).
end
());
value
=
LexicalCast
<
T
>
(
v
,
errmsg
);
boost
::
trim
(
value
);
++
it
;
}
}
else
else
{
{
value
.
swap
(
v
alue
_
)
;
value
=
defV
alue
;
}
}
}
}
}
// end namespace Utils
}
// end namespace Utils
...
...
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