]> Dogcows Code - chaz/yoink/blobdiff - src/moof/string.hh
remove some unused stlplus modules
[chaz/yoink] / src / moof / string.hh
index dd9d7918deb13ef9e27feab36423a66154db410d..4194abb08e1679d959b1a5cf58292df366ac241c 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_STRING_HH_
 #define _MOOF_STRING_HH_
@@ -28,7 +26,6 @@ namespace moof {
 using std::string;
 using std::wstring;
 
-
 /**
  * Convert a multi-byte (UTF-8) string to a wide string.
  * \param multi The multi-byte string to convert.
@@ -48,50 +45,48 @@ string wide_to_multi(const wstring& wide);
  * Class exposing the pattern-matching and substitution methods used in
  * Lua.
  */
-class regex : public boost::noncopyable
+class pattern : public boost::noncopyable
 {
 public:
 
        /**
-        * Construct a regex object.
+        * Construct a pattern object.
         */
-       regex() {}
+       pattern() {}
 
        /**
-        * Construct a regex object with a pattern.
+        * Construct a pattern object with a pattern.
         * \param pattern The pattern.
         */
-       regex(const string& pattern);
+       pattern(const std::string& pattern);
 
        /**
-        * Construct a regex object with a pattern and source to match.
+        * Construct a pattern object with a pattern and source to match.
         * \param pattern The pattern.
         * \param source The source string.
         */
-       regex(const string& pattern, const string& source);
+       pattern(const std::string& pattern, const std::string& source);
 
        /**
-        * Deconstruct the regex.
+        * Deconstruct the pattern.
         */
-       ~regex();
-
+       ~pattern();
 
        /**
-        * Get the regex pattern.
+        * Get the pattern pattern.
         */
-       string pattern() const;
+       std::string string() const;
 
        /**
-        * Set the regex pattern.
+        * Set the pattern string.
         */
-       void pattern(const string& pattern);
-
+       void string(const std::string& pattern);
 
        /**
         * Match a string against the pattern iteratively.
         * \param source The source string.
         */
-       void match(const string& source);
+       void match(const std::string& source);
 
        /**
         * Get the next match.  If the pattern contains captures, this version
@@ -99,7 +94,7 @@ public:
         * \param match Reference to a string to be assigned the match.
         * \return True if there was a match to get, false otherwise.
         */
-       bool get(string& match);
+       bool get(std::string& match);
 
        /**
         * Get the next match.  Use this version if the pattern contains more
@@ -107,8 +102,7 @@ public:
         * \param captures Reference to a vector of strings to hold the result.
         * \return True if there was a match to get, false otherwise.
         */
-       bool get(std::vector<string>& captures);
-
+       bool get(std::vector<std::string>& captures);
 
        /**
         * Match a string against a pattern all at one time.
@@ -117,12 +111,12 @@ public:
         * \param position The index of the first character of source to match.
         * \return The match.
         */
-       static string match(const string& pattern,
-                                               const string& source,
-                                               int position = 0)
+       static std::string
+       match(const std::string& pattern, const std::string& source,
+                       int position = 0)
        {
-               string match;
-               regex::match(match, pattern, source, position);
+               std::string match;
+               pattern::match(match, pattern, source, position);
                return match;
        }
 
@@ -134,10 +128,8 @@ public:
         * \param position The index of the first character of source to match.
         * \return True if a match was made, false otherwise.
         */
-       static bool match(string& match,
-                                         const string& pattern,
-                                         const string& source,
-                                         int position = 0);
+       static bool match(std::string& match, const std::string& pattern,
+                       const std::string& source, int position = 0);
 
        /**
         * Match a string against a pattern all at one time.  If the pattern
@@ -150,11 +142,8 @@ public:
         * \param position The index of the first character of source to match.
         * \return True if a match was made, false otherwise.
         */
-       static bool match(std::vector<string>& captures,
-                                         const string& pattern,
-                                         const string& source,
-                                         int position = 0);
-
+       static bool match(std::vector<std::string>& captures, const std::string& pattern,
+                       const std::string& source, int position = 0);
 
        /**
         * Substitute a string using a pattern and replacement string.
@@ -164,12 +153,11 @@ public:
         * references to captures.
         * \return The string with any substitutions made.
         */
-       static string sub(const string& pattern,
-                                         const string& source,
-                                         const string& replacement)
+       static std::string sub(const std::string& pattern,
+                       const std::string& source, const std::string& replacement)
        {
-               string substitution;
-               regex::sub(substitution, pattern, source, replacement);
+               std::string substitution;
+               pattern::sub(substitution, pattern, source, replacement);
                return substitution;
        }
 
@@ -182,14 +170,12 @@ public:
         * references to captures.
         * \return The number of substitutions made.
         */
-       static int sub(string& substitution,
-                                  const string& pattern,
-                                  const string& source,
-                                  const string& replacement);
+       static int sub(std::string& substitution, const std::string& pattern,
+                       const std::string& source, const std::string& replacement);
 };
 
 
 } // namespace moof
 
-#endif // _MOOF_STRINGTOOLS_HH_
+#endif // _MOOF_STRING_HH_
 
This page took 0.026056 seconds and 4 git commands to generate.