* TeMeL_SQLParser * FreeWare by eMeL



Version 1.03


Header:

//---------------------------------------------------------------------------
//
//  SQL select statement parser and rebuilder
//  --- ------ --------- ------ --- ---------
//
//  FREEWARE by eMeL (Laszlo Moravecz, Hungary) (Moravecz László)
//
//  news and updates: www.emel.hu/freeware/sqlparser   
//
//---------------------------------------------------------------------------

#ifndef eMeL_SQLParserH                 // eMeL_SQLParser.cpp
#define eMeL_SQLParserH

//---------------------------------------------------------------------------
//
//  WARNING!   SQL language keywords is tablename, fieldname, aliasname not allowed! 
//
//---------------------------------------------------------------------------

class TeMeL_SQLParser
{
private:

  enum tTokens {tokStart = -1, tokSelect, tokFrom, tokWhere, tokGroupBy, tokHaving, tokOrderBy};

  static char * sTokens[6];
  static char * sVersion;

  static char * sJoinTokens[10];

  tTokens iActToken;

  char *  SQLText;
  char *  SQLTextPtr;

  bool    isSeparator(char cChr);
  char *  CompareToken(char * sSrc, char * sToken);

  char *  TrimBothEnd(char * sStr);

  bool    NextTokenEnd(void);

  void    JoinOpener(void);

public:
  TeMeL_SQLParser();
  ~TeMeL_SQLParser();

  char *  FieldTag;         
  char *  TableTag;
  char *  JoinTag;
  char *  WhereTag;
  char *  GroupTag;
  char *  HavingTag;
  char *  OrderTag;

  void    Reset(void);

  bool    ParseSQLText(char * pSelectSmt);
  char *  BuildSQLText(void);

  bool    isBlankStr(char * sStr);
  bool    isValidSQL(void);

  const char * const GetVersion(void)  {return sVersion;};
};

//---------------------------------------------------------------------------
#endif

(c) FreeWare from eMeL Bt. (Moravecz László)