svn cleanup
[anytun.git] / Sockets / Parse.h
blob6961f3b1bc94603f6d59439afe38d8bbdaed508e
1 /** \file Parse.h - parse a string
2 **
3 ** Written: 1999-Feb-10 grymse@alhem.net
4 **/
6 /*
7 Copyright (C) 1999-2007 Anders Hedstrom
9 This library is made available under the terms of the GNU GPL.
11 If you would like to use this library in a closed-source application,
12 a separate license agreement is available. For information about
13 the closed-source license agreement for the C++ sockets library,
14 please visit http://www.alhem.net/Sockets/license.html and/or
15 email license@alhem.net.
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License
19 as published by the Free Software Foundation; either version 2
20 of the License, or (at your option) any later version.
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifndef _SOCKETS_Parse_H
33 #define _SOCKETS_Parse_H
35 #include "sockets-config.h"
36 #ifdef _MSC_VER
37 #pragma warning(disable:4514)
38 #endif
40 #include <string>
42 #ifdef SOCKETS_NAMESPACE
43 namespace SOCKETS_NAMESPACE {
44 #endif
47 /***************************************************/
48 /* interface of class Parse */
50 /** Splits a string whatever way you want.
51 \ingroup util */
52 class Parse
54 public:
55 Parse();
56 Parse(const std::string&);
57 Parse(const std::string&,const std::string&);
58 Parse(const std::string&,const std::string&,short);
59 ~Parse();
60 short issplit(const char);
61 void getsplit();
62 void getsplit(std::string&);
63 std::string getword();
64 void getword(std::string&);
65 void getword(std::string&,std::string&,int);
66 std::string getrest();
67 void getrest(std::string&);
68 long getvalue();
69 void setbreak(const char);
70 int getwordlen();
71 int getrestlen();
72 void enablebreak(const char c) {
73 pa_enable = c;
75 void disablebreak(const char c) {
76 pa_disable = c;
78 void getline();
79 void getline(std::string&);
80 size_t getptr() { return pa_the_ptr; }
81 void EnableQuote(bool b) { pa_quote = b; }
83 private:
84 std::string pa_the_str;
85 std::string pa_splits;
86 std::string pa_ord;
87 size_t pa_the_ptr;
88 char pa_breakchar;
89 char pa_enable;
90 char pa_disable;
91 short pa_nospace;
92 bool pa_quote;
96 #ifdef SOCKETS_NAMESPACE
98 #endif
100 #endif // _SOCKETS_Parse_H