diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-02-08 17:01:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-08 18:05:36 (GMT) |
commit | cfc2cf9559eacbf45d04249ee1dd7f75bb0cdff0 (patch) | |
tree | 608adc93feb8296339b4cd035ddf34a10995af94 | |
parent | f0ad6631adb7cd364e2bcf5e8738c697c902e0ad (diff) | |
download | CMake-cfc2cf9559eacbf45d04249ee1dd7f75bb0cdff0.zip CMake-cfc2cf9559eacbf45d04249ee1dd7f75bb0cdff0.tar.gz CMake-cfc2cf9559eacbf45d04249ee1dd7f75bb0cdff0.tar.bz2 |
cmGeneratorExpression: Tokenize over strings
-rw-r--r-- | Source/cmGeneratorExpression.cxx | 16 | ||||
-rw-r--r-- | Source/cmGeneratorExpression.h | 4 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionLexer.cxx | 6 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionLexer.h | 2 |
4 files changed, 13 insertions, 15 deletions
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 3ebb1b6..433adcf 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -33,17 +33,17 @@ cmGeneratorExpression::cmGeneratorExpression( cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(std::string const& input) { - return this->Parse(input.c_str()); + return cmsys::auto_ptr<cmCompiledGeneratorExpression>( + new cmCompiledGeneratorExpression( + this->Backtrace, + input)); } //---------------------------------------------------------------------------- cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(const char* input) { - return cmsys::auto_ptr<cmCompiledGeneratorExpression>( - new cmCompiledGeneratorExpression( - this->Backtrace, - input)); + return this->Parse(std::string(input ? input : "")); } cmGeneratorExpression::~cmGeneratorExpression() @@ -122,13 +122,13 @@ const char *cmCompiledGeneratorExpression::Evaluate( cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace const& backtrace, - const char *input) - : Backtrace(backtrace), Input(input ? input : ""), + const std::string& input) + : Backtrace(backtrace), Input(input), HadContextSensitiveCondition(false) { cmGeneratorExpressionLexer l; std::vector<cmGeneratorExpressionToken> tokens = - l.Tokenize(this->Input.c_str()); + l.Tokenize(this->Input); this->NeedsEvaluation = l.GetSawGeneratorExpression(); if (this->NeedsEvaluation) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 58abf14..9aa590d 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -100,7 +100,7 @@ public: ~cmCompiledGeneratorExpression(); - std::string GetInput() const + std::string const& GetInput() const { return this->Input; } @@ -116,7 +116,7 @@ public: private: cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, - const char *input); + const std::string& input); friend class cmGeneratorExpression; diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index 117a24e..1c83466 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -32,13 +32,11 @@ static void InsertText(const char *upto, const char *c, //---------------------------------------------------------------------------- std::vector<cmGeneratorExpressionToken> -cmGeneratorExpressionLexer::Tokenize(const char *input) +cmGeneratorExpressionLexer::Tokenize(const std::string& input) { std::vector<cmGeneratorExpressionToken> result; - if (!input) - return result; - const char *c = input; + const char *c = input.c_str(); const char *upto = c; for ( ; *c; ++c) diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h index 83d661d..1e2e8c2 100644 --- a/Source/cmGeneratorExpressionLexer.h +++ b/Source/cmGeneratorExpressionLexer.h @@ -43,7 +43,7 @@ class cmGeneratorExpressionLexer public: cmGeneratorExpressionLexer(); - std::vector<cmGeneratorExpressionToken> Tokenize(const char *input); + std::vector<cmGeneratorExpressionToken> Tokenize(const std::string& input); bool GetSawGeneratorExpression() const { |