Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-07-28 22:12:28 +0000
committerStijn Buys <ingar@osirion.org>2008-07-28 22:12:28 +0000
commitfa45b822bb8cdcd3fb3654ee099bdeddd2290a5c (patch)
treec47a52b6218d6531b546bccb1cbdc6200af65a12 /src/auxiliary/functions.cc
parent2acd2ce9ba60cd8c1535760d174e821ce345843d (diff)
label protection
Diffstat (limited to 'src/auxiliary/functions.cc')
-rw-r--r--src/auxiliary/functions.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/auxiliary/functions.cc b/src/auxiliary/functions.cc
index dbfc799..a6187af 100644
--- a/src/auxiliary/functions.cc
+++ b/src/auxiliary/functions.cc
@@ -143,4 +143,26 @@ void trim(std::string &text)
}
}
+void to_label(std::string &text)
+{
+ trim(text);
+ size_t pos = 0;
+
+ while (pos < text.size()) {
+ if ((text[pos] == ' ') || (text[pos] == '-')) {
+ text[pos] = '_';
+ pos++;
+ } else if ((text[pos] >= 'A') && (text[pos] <= 'Z')) {
+ text[pos] = text[pos] + 'a' - 'A';
+ pos++;
+ } else if ((text[pos] >= 'a') && (text[pos] <= 'z')) {
+ pos++;
+ } else if ((text[pos] >= '0') && (text[pos] <= '9')) {
+ pos++;
+ } else {
+ text.erase(pos, 1);
+ }
+ }
+}
+
}