home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 10 / amigaformatcd10.iso / -in_the_mag- / html_tutorial / parse.h < prev    next >
C/C++ Source or Header  |  1996-09-03  |  1KB  |  50 lines

  1. //
  2. // Split the components of a CGI result string into
  3. //  individual sub strings
  4. //
  5. // For example the string
  6. //   name=Your+name&action=%2B10%25&log=~mas/log
  7. //
  8. // is composed of three named elements:
  9. //
  10. //     Element    String associated with element
  11. //     name       Your name
  12. //     action     +10%
  13. //     log        /usr/staff/mas/log
  14. //
  15. // (C) M.A.Smith University of Brighton
  16. // Permission is granted to use this code
  17. //   provided this declaration and copyright notice remains intact.
  18. // 21 October 1995
  19. //
  20. //
  21. //
  22. // S p e c i f i c a t i o n
  23.  
  24. #ifndef CLASS_PARSE
  25. #define CLASS_PARSE
  26.  
  27. //#define NO_MAP  // Define for no ~user processing
  28.  
  29. #include "t99_type.h"
  30.  
  31. class Parse
  32. {
  33. public:
  34.   Parse( char [] );
  35.   ~Parse();
  36.   void set( char [] );
  37.   char *get_item( char [], int pos=1, bool=false );
  38.   char *get_item_n( char [], int pos=1, bool=false );
  39. protected:
  40.   void remove_escape(char []);   // Strip escape characters
  41.   int hex( char );               // Return hex value
  42.   char *map_uname( char [] );    // process ~uname -> home path
  43. private:
  44.   enum { SEP = '&' };            // Seperator for fields
  45.   char *the_str;                 // String parsed
  46.   int  the_length;               // Length of the string
  47. };
  48.  
  49. #endif
  50.