diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-01-01 22:34:47 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-01-01 22:34:47 (GMT) |
commit | 6244ac6f06a9723ac7d14545d3336b9dbb68bd9c (patch) | |
tree | cdf366cca9bb1dc446552fe895bf13edd318f751 /Source/cmStringCommand.cxx | |
parent | c8e546a353720f75dcc9282b254aba6d4e7db7ea (diff) | |
download | CMake-6244ac6f06a9723ac7d14545d3336b9dbb68bd9c.zip CMake-6244ac6f06a9723ac7d14545d3336b9dbb68bd9c.tar.gz CMake-6244ac6f06a9723ac7d14545d3336b9dbb68bd9c.tar.bz2 |
Add a way to convert ascii to string
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r-- | Source/cmStringCommand.cxx | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index f6e473a..a4d5518 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -33,7 +33,11 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args) else if(subCommand == "COMPARE") { 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()); @@ -41,6 +45,38 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args) } //---------------------------------------------------------------------------- +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) { if(args.size() < 2) |