summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-10-10 15:08:15 +0200
committerStephen Kelly <steveire@gmail.com>2015-10-10 15:36:59 +0200
commite2eecae20517daa2bb292f85e161d5cebbc1f216 (patch)
tree50a14e5929938c0716b4031e84b7bde66adbbf83
parentb5212c68def0395642fc51dcfd499557eb9481d9 (diff)
downloadcmake-e2eecae20517daa2bb292f85e161d5cebbc1f216.tar.gz
cmState: Move ParseCacheEntry from cmCacheManager.
-rw-r--r--Source/cmCacheManager.cxx86
-rw-r--r--Source/cmCacheManager.h6
-rw-r--r--Source/cmState.cxx84
-rw-r--r--Source/cmState.h6
-rw-r--r--Source/cmake.cxx4
5 files changed, 93 insertions, 93 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index bfa60b387a..ce8af55db3 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -27,90 +27,6 @@ cmCacheManager::cmCacheManager()
this->CacheMinorVersion = 0;
}
-static bool ParseEntryWithoutType(const std::string& entry,
- std::string& var,
- std::string& value)
-{
- // input line is: key=value
- static cmsys::RegularExpression reg(
- "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
- // input line is: "key"=value
- static cmsys::RegularExpression regQuoted(
- "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
- bool flag = false;
- if(regQuoted.find(entry))
- {
- var = regQuoted.match(1);
- value = regQuoted.match(2);
- flag = true;
- }
- else if (reg.find(entry))
- {
- var = reg.match(1);
- value = reg.match(2);
- flag = true;
- }
-
- // if value is enclosed in single quotes ('foo') then remove them
- // it is used to enclose trailing space or tab
- if (flag &&
- value.size() >= 2 &&
- value[0] == '\'' &&
- value[value.size() - 1] == '\'')
- {
- value = value.substr(1,
- value.size() - 2);
- }
-
- return flag;
-}
-
-bool cmCacheManager::ParseEntry(const std::string& entry,
- std::string& var,
- std::string& value,
- cmState::CacheEntryType& type)
-{
- // input line is: key:type=value
- static cmsys::RegularExpression reg(
- "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
- // input line is: "key":type=value
- static cmsys::RegularExpression regQuoted(
- "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
- bool flag = false;
- if(regQuoted.find(entry))
- {
- var = regQuoted.match(1);
- type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
- value = regQuoted.match(3);
- flag = true;
- }
- else if (reg.find(entry))
- {
- var = reg.match(1);
- type = cmState::StringToCacheEntryType(reg.match(2).c_str());
- value = reg.match(3);
- flag = true;
- }
-
- // if value is enclosed in single quotes ('foo') then remove them
- // it is used to enclose trailing space or tab
- if (flag &&
- value.size() >= 2 &&
- value[0] == '\'' &&
- value[value.size() - 1] == '\'')
- {
- value = value.substr(1,
- value.size() - 2);
- }
-
- if (!flag)
- {
- return ParseEntryWithoutType(entry, var, value);
- }
-
- return flag;
-}
-
void cmCacheManager::CleanCMakeFiles(const std::string& path)
{
std::string glob = path;
@@ -187,7 +103,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
}
}
e.SetProperty("HELPSTRING", helpString.c_str());
- if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type))
+ if(cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type))
{
if ( excludes.find(entryKey) == excludes.end() )
{
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index 24400663ab..6f063ebbcb 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -121,12 +121,6 @@ public:
int GetSize() {
return static_cast<int>(this->Cache.size()); }
- ///! Break up a line like VAR:type="value" into var, type and value
- static bool ParseEntry(const std::string& entry,
- std::string& var,
- std::string& value,
- cmState::CacheEntryType& type);
-
///! Get a value from the cache given a key
const char* GetInitializedCacheValue(const std::string& key) const;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 3aad7f5d62..c5bbf42cc7 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -1769,3 +1769,87 @@ bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
{
return lhs.Position != rhs.Position;
}
+
+static bool ParseEntryWithoutType(const std::string& entry,
+ std::string& var,
+ std::string& value)
+{
+ // input line is: key=value
+ static cmsys::RegularExpression reg(
+ "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+ // input line is: "key"=value
+ static cmsys::RegularExpression regQuoted(
+ "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+ bool flag = false;
+ if(regQuoted.find(entry))
+ {
+ var = regQuoted.match(1);
+ value = regQuoted.match(2);
+ flag = true;
+ }
+ else if (reg.find(entry))
+ {
+ var = reg.match(1);
+ value = reg.match(2);
+ flag = true;
+ }
+
+ // if value is enclosed in single quotes ('foo') then remove them
+ // it is used to enclose trailing space or tab
+ if (flag &&
+ value.size() >= 2 &&
+ value[0] == '\'' &&
+ value[value.size() - 1] == '\'')
+ {
+ value = value.substr(1,
+ value.size() - 2);
+ }
+
+ return flag;
+}
+
+bool cmState::ParseCacheEntry(const std::string& entry,
+ std::string& var,
+ std::string& value,
+ CacheEntryType& type)
+{
+ // input line is: key:type=value
+ static cmsys::RegularExpression reg(
+ "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+ // input line is: "key":type=value
+ static cmsys::RegularExpression regQuoted(
+ "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+ bool flag = false;
+ if(regQuoted.find(entry))
+ {
+ var = regQuoted.match(1);
+ type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
+ value = regQuoted.match(3);
+ flag = true;
+ }
+ else if (reg.find(entry))
+ {
+ var = reg.match(1);
+ type = cmState::StringToCacheEntryType(reg.match(2).c_str());
+ value = reg.match(3);
+ flag = true;
+ }
+
+ // if value is enclosed in single quotes ('foo') then remove them
+ // it is used to enclose trailing space or tab
+ if (flag &&
+ value.size() >= 2 &&
+ value[0] == '\'' &&
+ value[value.size() - 1] == '\'')
+ {
+ value = value.substr(1,
+ value.size() - 2);
+ }
+
+ if (!flag)
+ {
+ return ParseEntryWithoutType(entry, var, value);
+ }
+
+ return flag;
+}
diff --git a/Source/cmState.h b/Source/cmState.h
index 4c32831b6a..fbc9275de9 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -242,6 +242,12 @@ public:
void RemoveCacheEntryProperty(std::string const& key,
std::string const& propertyName);
+ ///! Break up a line like VAR:type="value" into var, type and value
+ static bool ParseCacheEntry(const std::string& entry,
+ std::string& var,
+ std::string& value,
+ CacheEntryType& type);
+
Snapshot Reset();
// Define a property
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index b90ac6943b..b1c2709192 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -216,7 +216,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
}
std::string var, value;
cmState::CacheEntryType type = cmState::UNINITIALIZED;
- if(cmCacheManager::ParseEntry(entry, var, value, type))
+ if(cmState::ParseCacheEntry(entry, var, value, type))
{
// The value is transformed if it is a filepath for example, so
// we can't compare whether the value is already in the cache until
@@ -1722,7 +1722,7 @@ bool cmake::ParseCacheEntry(const std::string& entry,
std::string& value,
cmState::CacheEntryType& type)
{
- return cmCacheManager::ParseEntry(entry, var, value, type);
+ return cmState::ParseCacheEntry(entry, var, value, type);
}
int cmake::LoadCache()