aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2011-10-09 16:03:04 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2011-10-14 23:04:29 +0100
commit6779001d17d4a16ddd1a5cf0f6300307dddd18a5 (patch)
tree21d991b5c9ed8edfe6a4f8331972ade5bf6fa985
parent7c26476a765af03fdad2c6e5e9de49bbb0438520 (diff)
downloadpaludis-6779001d17d4a16ddd1a5cf0f6300307dddd18a5.tar.gz
paludis-6779001d17d4a16ddd1a5cf0f6300307dddd18a5.tar.xz
Add functions to upper/lower-case entire strings
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/upper_lower.cc42
-rw-r--r--paludis/util/upper_lower.hh32
3 files changed, 75 insertions, 0 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index f29724c..28a780c 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -91,6 +91,7 @@ add(`timestamp', `hh', `cc', `fwd')
add(`tokeniser', `hh', `cc', `gtest')
add(`tribool', `hh', `cc', `fwd', `gtest')
add(`type_list', `hh', `cc', `fwd')
+add(`upper_lower', `hh', `cc')
add(`util', `hh')
add(`visitor', `hh', `cc', `fwd', `impl')
add(`visitor_cast', `hh', `cc', `fwd')
diff --git a/paludis/util/upper_lower.cc b/paludis/util/upper_lower.cc
new file mode 100644
index 0000000..1fe6561
--- /dev/null
+++ b/paludis/util/upper_lower.cc
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 David Leverton
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/util/upper_lower.hh>
+#include <cctype>
+#include <algorithm>
+
+namespace paludis
+{
+ std::string toupper(const std::string & s)
+ {
+ std::string r;
+ std::transform(s.begin(), s.end(), std::back_inserter(r), static_cast<int (*)(int)>(std::toupper));
+ return r;
+ }
+
+ std::string tolower(const std::string & s)
+ {
+ std::string r;
+ std::transform(s.begin(), s.end(), std::back_inserter(r), static_cast<int (*)(int)>(std::tolower));
+ return r;
+ }
+}
+
+
+
diff --git a/paludis/util/upper_lower.hh b/paludis/util/upper_lower.hh
new file mode 100644
index 0000000..9fe7870
--- /dev/null
+++ b/paludis/util/upper_lower.hh
@@ -0,0 +1,32 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 David Leverton
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_UPPER_LOWER_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_UPPER_LOWER_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <string>
+
+namespace paludis
+{
+ std::string toupper(const std::string & s) PALUDIS_VISIBLE;
+ std::string tolower(const std::string & s) PALUDIS_VISIBLE;
+}
+
+#endif