Google
Web alhem.net

Cgi::Parse Class Reference

#include <Parse.h>

Collaboration diagram for Cgi::Parse:

Collaboration graph
List of all members.

Public Member Functions

 Parse ()
 Parse (const char *)
 Parse (const char *, const char *)
 Parse (const char *, const char *, short)
 ~Parse ()
short issplit (char)
void getsplit ()
void getsplit (char *)
std::string getword ()
void getword (char *)
void getword (char *, int)
void getword (char *, char *, int)
void getrest (char *)
long getvalue ()
void setbreak (char)
int getwordlen ()
int getrestlen ()
void enablebreak (char)
void disablebreak (char)
void getline ()
void getline (char *)
void getline (char *, int)
int getptr ()
void EnableQuote (bool b)

Private Member Functions

 Parse (const Parse &)
Parseoperator= (const Parse &)

Private Attributes

char * pa_the_str
char * pa_splits
char * pa_ord
int pa_the_ptr
char pa_breakchar
char pa_enable
char pa_disable
short pa_nospace
bool pa_quote

Detailed Description

Definition at line 38 of file Parse.h.


Constructor & Destructor Documentation

Cgi::Parse::Parse (  ) 

Definition at line 39 of file Parse.cpp.

References pa_breakchar, pa_disable, pa_enable, pa_nospace, pa_ord, pa_quote, pa_splits, pa_the_ptr, and pa_the_str.

00040 {
00041         pa_the_str = NULL;
00042         pa_splits = NULL;
00043         pa_ord = NULL;
00044         pa_the_ptr = 0;
00045         pa_breakchar = 0;
00046         pa_enable = pa_disable = 0;
00047         pa_nospace = 0;
00048         pa_quote = false;
00049 }

Cgi::Parse::Parse ( const char *   ) 

Definition at line 51 of file Parse.cpp.

References pa_breakchar, pa_disable, pa_enable, pa_nospace, pa_ord, pa_quote, pa_splits, pa_the_ptr, and pa_the_str.

00052 {
00053         pa_the_str = NULL;
00054         pa_splits = NULL;
00055         pa_ord = NULL;
00056         pa_the_ptr = 0;
00057         pa_breakchar = 0;
00058         pa_enable = pa_disable = 0;
00059         pa_nospace = 0;
00060         pa_quote = false;
00061 
00062         pa_the_str = new char[strlen(s) + 1];
00063         strcpy(pa_the_str,s);
00064         pa_ord = new char[strlen(s) + 1];
00065         *pa_ord = 0;
00066 }

Cgi::Parse::Parse ( const char *  ,
const char *   
)

Definition at line 68 of file Parse.cpp.

References pa_breakchar, pa_disable, pa_enable, pa_nospace, pa_ord, pa_quote, pa_splits, pa_the_ptr, and pa_the_str.

00069 {
00070         pa_the_str = NULL;
00071         pa_splits = NULL;
00072         pa_ord = NULL;
00073         pa_the_ptr = 0;
00074         pa_breakchar = 0;
00075         pa_enable = pa_disable = 0;
00076         pa_nospace = 0;
00077         pa_quote = false;
00078 
00079         pa_the_str = new char[strlen(s) + 1];
00080         strcpy(pa_the_str,s);
00081         pa_splits = new char[strlen(sp) + 1];
00082         strcpy(pa_splits,sp);
00083         pa_ord = new char[strlen(s) + 1];
00084         *pa_ord = 0;
00085 }

Cgi::Parse::Parse ( const char *  ,
const char *  ,
short   
)

Definition at line 87 of file Parse.cpp.

References pa_breakchar, pa_disable, pa_enable, pa_nospace, pa_ord, pa_quote, pa_splits, pa_the_ptr, and pa_the_str.

00088 {
00089         pa_the_str = NULL;
00090         pa_splits = NULL;
00091         pa_ord = NULL;
00092         pa_the_ptr = 0;
00093         pa_breakchar = 0;
00094         pa_enable = pa_disable = 0;
00095         pa_nospace = 0;
00096         pa_quote = false;
00097 
00098         pa_the_str = new char[strlen(s) + 1];
00099         strcpy(pa_the_str,s);
00100         pa_splits = new char[strlen(sp) + 1];
00101         strcpy(pa_splits,sp);
00102         pa_ord = new char[strlen(s) + 1];
00103         *pa_ord = 0;
00104         pa_nospace = 1;
00105 }

Cgi::Parse::~Parse (  ) 

Definition at line 107 of file Parse.cpp.

References pa_ord, pa_splits, and pa_the_str.

00108 {
00109   if (pa_the_str)
00110     delete[] pa_the_str;
00111   if (pa_splits)
00112     delete[] pa_splits;
00113   if (pa_ord)
00114     delete[] pa_ord;
00115 }

Cgi::Parse::Parse ( const Parse  )  [private]

Definition at line 357 of file Parse.cpp.

00358 {
00359 }


Member Function Documentation

short Cgi::Parse::issplit ( char   ) 

Definition at line 120 of file Parse.cpp.

References pa_splits.

Referenced by getrest(), getrestlen(), getsplit(), getword(), and getwordlen().

00121 {
00122         short i;
00123 
00124         if (pa_splits)
00125                 for (i = 0; (size_t)i < strlen(pa_splits); i++)
00126                         if (pa_splits[i] == c)
00127                                 return 1;
00128         return 0;
00129 }

void Cgi::Parse::getsplit (  ) 

Definition at line 131 of file Parse.cpp.

References C, issplit(), pa_ord, pa_the_ptr, and pa_the_str.

Referenced by getsplit().

00132 {
00133         int x;
00134 
00135         if (C == '=')
00136         {
00137                 x = pa_the_ptr++;
00138         } else
00139         {
00140                 while (C && (issplit(C)))
00141                         pa_the_ptr++;
00142                 x = pa_the_ptr;
00143                 while (C && !issplit(C) && C != '=')
00144                         pa_the_ptr++;
00145         }
00146         if (x == pa_the_ptr && C == '=')
00147                 pa_the_ptr++;
00148         strncpy(pa_ord,pa_the_str + x,pa_the_ptr - x);
00149         pa_ord[pa_the_ptr - x] = 0;
00150 }

void Cgi::Parse::getsplit ( char *   ) 

Definition at line 241 of file Parse.cpp.

References getsplit(), and pa_ord.

00242 {
00243         Parse::getsplit();
00244         strcpy(s,pa_ord);
00245 }

std::string Cgi::Parse::getword (  ) 

Definition at line 152 of file Parse.cpp.

References C, DEB, issplit(), pa_breakchar, pa_disable, pa_enable, pa_nospace, pa_ord, pa_quote, pa_the_ptr, and pa_the_str.

Referenced by Cgi::Form::Form(), getvalue(), getword(), and Cgi::Web::ValidateAuth().

00153 {
00154         int x;
00155         int disabled = 0;
00156         int quote = 0;
00157 
00158         if (pa_nospace)
00159         {
00160                 while (C && issplit(C))
00161                         pa_the_ptr++;
00162                 x = pa_the_ptr;
00163                 while (C && !issplit(C) && (C != pa_breakchar || !pa_breakchar || disabled))
00164                 {
00165                         if (pa_breakchar && C == pa_disable)
00166                                 disabled = 1;
00167                         if (pa_breakchar && C == pa_enable)
00168                                 disabled = 0;
00169                         if (pa_quote && C == '"')
00170                                 quote = 1;
00171                         pa_the_ptr++;
00172                         while (quote && C && C != '"')
00173                         {
00174                                 pa_the_ptr++;
00175                         }
00176                         if (pa_quote && C == '"')
00177                         {
00178                                 pa_the_ptr++;
00179                         }
00180                         quote = 0;
00181                 }
00182         } else
00183         {
00184                 if (C == pa_breakchar && pa_breakchar)
00185                 {
00186                         x = pa_the_ptr++;
00187                 } else
00188                 {
00189                         while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
00190                                 pa_the_ptr++;
00191                         x = pa_the_ptr;
00192 #define DEB(x) 
00193 DEB(printf("Split starts at %d\n",x);)
00194                         while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) &&
00195                          (C != pa_breakchar || !pa_breakchar || disabled))
00196                         {
00197 DEB(printf("Char '%c'\n",C);)
00198                                 if (pa_breakchar && C == pa_disable)
00199                                         disabled = 1;
00200                                 if (pa_breakchar && C == pa_enable)
00201                                         disabled = 0;
00202                                 if (pa_quote && C == '"')
00203                                 {
00204                                         quote = 1;
00205                                 pa_the_ptr++;
00206                                 while (quote && C && C != '"')
00207                                 {
00208                                         pa_the_ptr++;
00209                                 }
00210                                 if (pa_quote && C == '"')
00211                                 {
00212                                         pa_the_ptr++;
00213                                 }
00214                                 }
00215                                 else
00216                                         pa_the_ptr++;
00217                                 quote = 0;
00218                         }
00219                 }
00220                 if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
00221                         pa_the_ptr++;
00222         }
00223         strncpy(pa_ord,pa_the_str + x,pa_the_ptr - x);
00224         pa_ord[pa_the_ptr - x] = 0;
00225         return pa_ord;
00226 }

void Cgi::Parse::getword ( char *   ) 

Definition at line 228 of file Parse.cpp.

References getword(), and pa_ord.

00229 {
00230         Parse::getword();
00231         strcpy(s,pa_ord);
00232 }

void Cgi::Parse::getword ( char *  ,
int   
)

Definition at line 234 of file Parse.cpp.

References getword(), and pa_ord.

00235 {
00236         Parse::getword();
00237         strncpy(s,pa_ord,l - 1);
00238         s[l - 1] = 0;
00239 }

void Cgi::Parse::getword ( char *  ,
char *  ,
int   
)

Definition at line 247 of file Parse.cpp.

References getword(), and pa_ord.

00248 {
00249         Parse::getword();
00250         *s = 0;
00251         while (strlen(s) + strlen(pa_ord) < (size_t)l)
00252                 strcat(s,fill);
00253         strcat(s,pa_ord);
00254 }

void Cgi::Parse::getrest ( char *   ) 

Definition at line 256 of file Parse.cpp.

References C, issplit(), pa_the_ptr, and pa_the_str.

Referenced by Cgi::Form::Form().

00257 {
00258         while (C && (C == ' ' || C == 9 || issplit(C)))
00259                 pa_the_ptr++;
00260         strcpy(s,pa_the_str + pa_the_ptr);
00261 }

long Cgi::Parse::getvalue (  ) 

Definition at line 263 of file Parse.cpp.

References getword(), and pa_ord.

Referenced by Cgi::MenuWeb::ReadCookies().

00264 {
00265         Parse::getword();
00266         return atol(pa_ord);
00267 }

void Cgi::Parse::setbreak ( char   ) 

Definition at line 269 of file Parse.cpp.

References pa_breakchar.

00270 {
00271         pa_breakchar = c;
00272 }

int Cgi::Parse::getwordlen (  ) 

Definition at line 274 of file Parse.cpp.

References C, issplit(), pa_breakchar, and pa_the_ptr.

00275 {
00276         int x,y = pa_the_ptr,len;
00277 
00278         if (C == pa_breakchar && pa_breakchar)
00279         {
00280                 x = pa_the_ptr++;
00281         } else
00282         {
00283                 while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
00284                         pa_the_ptr++;
00285                 x = pa_the_ptr;
00286                 while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) && (C != pa_breakchar || !pa_breakchar))
00287                         pa_the_ptr++;
00288         }
00289         if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
00290                 pa_the_ptr++;
00291         len = pa_the_ptr - x;
00292         pa_the_ptr = y;
00293         return len;
00294 }

int Cgi::Parse::getrestlen (  ) 

Definition at line 296 of file Parse.cpp.

References C, issplit(), pa_the_ptr, and pa_the_str.

00297 {
00298         int y = pa_the_ptr,len;
00299 
00300         while (C && (C == ' ' || C == 9 || issplit(C)))
00301                 pa_the_ptr++;
00302         len = strlen(pa_the_str + pa_the_ptr);
00303         pa_the_ptr = y;
00304         return len;
00305 }

void Cgi::Parse::enablebreak ( char   ) 

Definition at line 337 of file Parse.cpp.

References pa_enable.

00338 {
00339         pa_enable = c;
00340 }

void Cgi::Parse::disablebreak ( char   ) 

Definition at line 342 of file Parse.cpp.

References pa_disable.

00343 {
00344         pa_disable = c;
00345 }

void Cgi::Parse::getline (  ) 

Definition at line 307 of file Parse.cpp.

References C, pa_ord, pa_the_ptr, and pa_the_str.

Referenced by getline().

00308 {
00309         int x;
00310 
00311 //      while (C && (C == 13 || C == 10))
00312 //              pa_the_ptr++;
00313         x = pa_the_ptr;
00314         while (C && C != 13 && C != 10)
00315                 pa_the_ptr++;
00316         strncpy(pa_ord,pa_the_str + x,pa_the_ptr - x);
00317         pa_ord[pa_the_ptr - x] = 0;
00318         if (C == 13)
00319                 pa_the_ptr++;
00320         if (C == 10)
00321                 pa_the_ptr++;
00322 }

void Cgi::Parse::getline ( char *   ) 

Definition at line 324 of file Parse.cpp.

References getline(), and pa_ord.

00325 {
00326         getline();
00327         strcpy(s,pa_ord);
00328 }

void Cgi::Parse::getline ( char *  ,
int   
)

Definition at line 330 of file Parse.cpp.

References getline(), and pa_ord.

00331 {
00332         getline();
00333         strncpy(s,pa_ord,l - 1);
00334         s[l - 1] = 0;
00335 }

int Cgi::Parse::getptr (  ) 

Definition at line 347 of file Parse.cpp.

References pa_the_ptr.

00348 { 
00349   return pa_the_ptr; 
00350 }

void Cgi::Parse::EnableQuote ( bool  b  ) 

Definition at line 352 of file Parse.cpp.

References pa_quote.

Referenced by Cgi::Form::Form().

00353 { 
00354   pa_quote = b; 
00355 }

Parse & Cgi::Parse::operator= ( const Parse  )  [private]

Definition at line 361 of file Parse.cpp.

00362 { 
00363   return *this; 
00364 }


Member Data Documentation

char* Cgi::Parse::pa_the_str [private]

Definition at line 69 of file Parse.h.

Referenced by getline(), getrest(), getrestlen(), getsplit(), getword(), Parse(), and ~Parse().

char* Cgi::Parse::pa_splits [private]

Definition at line 70 of file Parse.h.

Referenced by issplit(), Parse(), and ~Parse().

char* Cgi::Parse::pa_ord [private]

Definition at line 71 of file Parse.h.

Referenced by getline(), getsplit(), getvalue(), getword(), Parse(), and ~Parse().

int Cgi::Parse::pa_the_ptr [private]

Definition at line 72 of file Parse.h.

Referenced by getline(), getptr(), getrest(), getrestlen(), getsplit(), getword(), getwordlen(), and Parse().

char Cgi::Parse::pa_breakchar [private]

Definition at line 73 of file Parse.h.

Referenced by getword(), getwordlen(), Parse(), and setbreak().

char Cgi::Parse::pa_enable [private]

Definition at line 74 of file Parse.h.

Referenced by enablebreak(), getword(), and Parse().

char Cgi::Parse::pa_disable [private]

Definition at line 75 of file Parse.h.

Referenced by disablebreak(), getword(), and Parse().

short Cgi::Parse::pa_nospace [private]

Definition at line 76 of file Parse.h.

Referenced by getword(), and Parse().

bool Cgi::Parse::pa_quote [private]

Definition at line 77 of file Parse.h.

Referenced by EnableQuote(), getword(), and Parse().


The documentation for this class was generated from the following files:
Generated for cgi++ by doxygen 1.3.7

Page, code, and content Copyright (C) 2004 by Anders Hedström