## root/include/wstring.h

/* [<][>][^][v][top][bottom][index][help] */

## INCLUDED FROM

    /* Definition of the word string class
       Rick Smereka, Copyright (C) 2000-2002.

       This program is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published by
       the Free Software Foundation; either version 2 of the License, or
       (at your option) any later version.

       This program 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, get a copy via the Internet at
       http://gnu.org/copyleft/gpl.html or write to the Free Software
       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       MA 02111-1307 USA

       You can contact the author via email at rsmereka@future-lab.com

       Original version, Oct/2000, Rick Smereka

       Ported to Debian Linux. Nov/2002, Rick Smereka

       Added 'using namespace std'. Dec/2002, Rick Smereka */

    #ifndef WSTRING_HXX
    #define WSTRING_HXX

    using namespace std;

    class word_string
       {
       private:
          string ws_contents;

       public:
          // constructors
          word_string() { ws_contents = ""; }
          word_string(string& text) { ws_contents = text; }
          word_string(char *text);
          word_string(word_string& o_string);
          word_string(const word_string& o_string);
          word_string(char ch, int cnt);

          // destructor
          ~word_string() { ws_contents == ""; }

          // operators
          void operator = (word_string str) { ws_contents = str.ws_contents; }
          void operator = (char *str) { ws_contents = str; }
          void operator = (char ch) { ws_contents = ch; }
          void operator = (string str) { ws_contents = str; }
          friend word_string operator + (word_string str1, word_string str2);
          friend word_string operator + (word_string str1, string str2);
          friend word_string operator + (string str1, word_string str2);
          friend word_string operator + (word_string str1, char *str2);
          friend word_string operator + (char *str1, word_string str2);
          friend word_string operator + (word_string str1, char ch);
          friend word_string operator + (char ch, word_string str1);
          void operator += (word_string str) { ws_contents += str.ws_contents; }
          void operator += (char *str) { ws_contents += str; }
          void operator += (char ch) { ws_contents += ch; }
          void operator += (string str) { ws_contents += str; }
          char operator [] (int pos);
          bool operator == (word_string& s) { return(ws_contents == s.ws_contents); }
          bool operator == (string& s) { return(ws_contents == s); }
          bool operator == (char *s) { return(ws_contents == s); }
          bool operator == (char ch);
          bool operator != (word_string& s) { return(ws_contents != s.ws_contents); }
          bool operator != (string& s) { return(ws_contents != s); }
          bool operator != (char *s) { return(ws_contents != s); }
          bool operator != (char ch);
          bool operator < (word_string& s) { return(ws_contents < s.ws_contents); }
          bool operator < (string& s) { return(ws_contents < s); }
          bool operator < (char *s) { return(ws_contents < s); }
          bool operator <= (word_string& s) { return(ws_contents <= s.ws_contents); }
          bool operator <= (string& s) { return(ws_contents <= s); }
          bool operator <= (char *s) { return(ws_contents <= s); }
          bool operator > (word_string& s) { return(ws_contents > s.ws_contents); }
          bool operator > (string& s) { return(ws_contents > s); }
          bool operator > (char *s) { return(ws_contents > s); }
          bool operator >= (word_string& s) { return(ws_contents >= s.ws_contents); }
          bool operator >= (string& s) { return(ws_contents >= s); }
          bool operator >= (char *s) { return(ws_contents >= s); }

          // word string output
          friend ostream& operator <<(ostream & out, const word_string& wstr) { out << wstr.ws_contents; return out; }

          // member functions
          int length(void) { ws_contents.length(); }
          bool empty(void);
          void clear(void) { ws_contents = ""; }
          void show(void);
          word_string substr(int pos, int len);
          word_string left(int len = 1);
          word_string right(int len = 1);
          word_string trim(void);
          word_string ucase(void);
          word_string lcase(void);
          int words(char delim = ' ');
          int indxword(int which, char delim = ' ');
          int wordlen(int which, char delim = ' ');
          bool word(word_string& outstr, int which = 1, char delim = ' ');
          int command_words(void);
          int command_indxword(int which);
          int command_wordlen(int which);
          bool command_word(word_string& o_string, int which);
          int find(word_string& sub);
          int find_char(char findch);
          bool command_worddel(int which);
          bool worddel(int which = 1, char delim = ' ');
          bool wordput(word_string& wdata, int which = 1, char delim = ' ');
          bool num(void);
          bool parse_extend(int which, char delim);
          bool str_replace(int spos, word_string& wdata);
       };
    #endif                                          // WSTRING_HXX

/* [<][>][^][v][top][bottom][index][help] */