Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
6244ac6f
Commit
6244ac6f
authored
Jan 01, 2003
by
Andy Cedilnik
Browse files
Add a way to convert ascii to string
parent
c8e546a3
Changes
2
Show whitespace changes
Inline
Side-by-side
Source/cmStringCommand.cxx
View file @
6244ac6f
...
...
@@ -34,12 +34,48 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args)
{
return
this
->
HandleCompareCommand
(
args
);
}
else
if
(
subCommand
==
"ASCII"
)
{
return
this
->
HandleAsciiCommand
(
args
);
}
std
::
string
e
=
"does not recognize sub-command "
+
subCommand
;
this
->
SetError
(
e
.
c_str
());
return
false
;
}
//----------------------------------------------------------------------------
bool
cmStringCommand
::
HandleAsciiCommand
(
std
::
vector
<
std
::
string
>
const
&
args
)
{
if
(
args
.
size
()
<=
1
)
{
this
->
SetError
(
"No output variable specified"
);
return
false
;
}
std
::
string
::
size_type
cc
;
std
::
string
outvar
=
args
[
args
.
size
()
-
1
];
std
::
string
output
=
""
;
for
(
cc
=
1
;
cc
<
args
.
size
()
-
1
;
cc
++
)
{
int
ch
=
atoi
(
args
[
cc
].
c_str
());
if
(
ch
>
0
&&
ch
<
256
)
{
output
+=
static_cast
<
char
>
(
ch
);
}
else
{
std
::
string
error
=
"Character with code "
;
error
+=
ch
;
error
+=
" does not exist."
;
this
->
SetError
(
error
.
c_str
());
return
false
;
}
}
// Store the output in the provided variable.
m_Makefile
->
AddDefinition
(
outvar
.
c_str
(),
output
.
c_str
());
return
true
;
}
//----------------------------------------------------------------------------
bool
cmStringCommand
::
HandleRegexCommand
(
std
::
vector
<
std
::
string
>
const
&
args
)
{
...
...
Source/cmStringCommand.h
View file @
6244ac6f
...
...
@@ -67,16 +67,19 @@ public:
"STRING(COMPARE NOTEQUAL <string1> <string2> <output variable>)
\n
"
"STRING(COMPARE LESS <string1> <string2> <output variable>)
\n
"
"STRING(COMPARE GREATER <string1> <string2> <output variable>)
\n
"
"STRING(ASCII <number> [<number> ...] <output variable>)
\n
"
"REGEX MATCH will match the regular expression once and store the match in the output variable.
\n
"
"REGEX MATCHALL will match the regular expression as many times as possible and store the matches
\n
"
" in the output variable as a list.
\n
"
"REGEX REPLACE will match the regular expression as many times as possible and substitute the
\n
"
" replacement expression for the match in the output.
\n
"
"COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and store true or false in the output variable.
\n
"
;
"COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and store true or false in the output variable.
\n
"
"ASCII will convert all numbers into corresponding ASCII characters.
\n
"
;
}
cmTypeMacro
(
cmStringCommand
,
cmCommand
);
protected:
bool
HandleAsciiCommand
(
std
::
vector
<
std
::
string
>
const
&
args
);
bool
HandleRegexCommand
(
std
::
vector
<
std
::
string
>
const
&
args
);
bool
RegexMatch
(
std
::
vector
<
std
::
string
>
const
&
args
);
bool
RegexMatchAll
(
std
::
vector
<
std
::
string
>
const
&
args
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment