// $Source: /usr/local/SimSoft/SoftShop/Basics/io/Token.h,v $
// $Revision: 1.19 $
// $Author: baum $
// $Date: 2001/11/29 15:52:23 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-20 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: Token.h,v $
// Revision 1.19  2001/11/29 15:52:23  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//

#ifndef _TOKEN_H
#define _TOKEN_H 1

#ifdef  _MSC_VER
#pragma warning(disable:4275)
#endif  // _MSC_VER

#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include "Strings.h"

#ifdef _TOKEN_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_BASICS_DLL
#  undef _impexp
#  define _impexp __declspec(dllexport)
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

#if defined __GNUG__ || defined __hpux
#  undef _impexp
#  define _impexp
#endif

//==================================================================
//		class header
//		for class InputFile
//==================================================================

//##ModelId=3FBCBCC30293
class _impexp InputFile: public ifstream {
  public:
    // constructor (open as binary)
	//##ModelId=3FBCBCC30295
    InputFile(const char *fileName);

    // destructor
	//##ModelId=3FBCBCC30297
    virtual ~InputFile ();

	//##ModelId=3FBCBCC302A0
    char readChar ();
	//##ModelId=3FBCBCC302A1
    void readChar (char& c);
	//##ModelId=3FBCBCC302A3
    Ustring FileName (); //Norman 14.10.01 Erweiterung für "DEF" und "USE" in BaseVrmlParser
	//##ModelId=3FBCBCC302A4
    Ustring PathName ();

    // ignoring maximal n chars
    // but stop at c
	//##ModelId=3FBCBCC302AF
    void jump (unsigned n = 1, char c = '\n');

    // get actual Linenumber
	//##ModelId=3FBCBCC302B2
    unsigned LineNumber () const;

  private:
    // data-members
	//##ModelId=3FBCBCC302C0
    unsigned ObjLineNumber;
	//##ModelId=3FBCBCC302CE
    char ObjCurrentChar;
	//##ModelId=3FBCBCC3031D
    Ustring ObjFileName; //Norman 14.10.01 Erweiterung für "DEF" und "USE" in BaseVrmlParser
	//##ModelId=3FBCBCC30322
    Ustring ObjPathName; // Lars 04.06.03 Pfad ohne Dateiname

	//##ModelId=3FBCBCC3032C
    InputFile ();
	//##ModelId=3FBCBCC3032D
    InputFile (const InputFile&);
	//##ModelId=3FBCBCC3033C
    InputFile& operator = (const InputFile&);

};

//==================================================================
//		class header
//		for abstract class Token 
//==================================================================

//##ModelId=3FBCBCC3035B
class _impexp Token {
  public:
    // parse next Token from stream
    // looking for nothing than isspace and EOF
	//##ModelId=3FBCBCC3036B
    virtual streampos nextToken (InputFile&);

    // () operator to get access
	//##ModelId=3FBCBCC3036E
    char* operator () ();

    // the type of the current token
	//##ModelId=3FBCBCC3037A
    bool isInt     ();
	//##ModelId=3FBCBCC3037B
    bool isFloat   ();
	//##ModelId=3FBCBCC3037C
    bool isDouble  ();
	//##ModelId=3FBCBCC3037D
    bool isBlock   ();
	//##ModelId=3FBCBCC3037E
    bool isBracket ();
	//##ModelId=3FBCBCC3038A
    bool isOpenBracket  ();
	//##ModelId=3FBCBCC3038B
    bool isCloseBracket ();

  protected:
    // constructor
	//##ModelId=3FBCBCC3038C
    Token ();

    // destructor
	//##ModelId=3FBCBCC3038D
    virtual ~Token ();

    // data members
	//##ModelId=3FBCBCC30399
    char ObjData[1024];
	//##ModelId=3FBCBCC3039A
    char ObjComment;
	//##ModelId=3FBCBCC303A9
    char ObjLeadingBlockDelimit;
	//##ModelId=3FBCBCC303AA
    char ObjEndingBlockDelimit;
	//##ModelId=3FBCBCC303AB
    char ObjSequenz;

    // some proof-functions
	//##ModelId=3FBCBCC303B9
    bool iscomment (char c);
	//##ModelId=3FBCBCC303BB
    bool issequenz (char c);

    // some static proof-functions
	//##ModelId=3FBCBCC303C9
    static bool isint     (char c);
	//##ModelId=3FBCBCC303CC
    static bool isreal    (char c); // means float and/or double !!!
	//##ModelId=3FBCBCC303D9
    static bool isbracket (char c);
	//##ModelId=3FBCBCC303DC
    static bool isopenbracket  (char c);
	//##ModelId=3FBCBCC40001
    static bool isclosebracket (char c);

  private:
	//##ModelId=3FBCBCC40004
    Token (const Token&);
	//##ModelId=3FBCBCC4000F
    Token& operator = (const Token&);

  // friends

};

//==================================================================
//		the declaration
//		for global comparison functions
//==================================================================

inline bool operator == (Token& t, char* str) {
  return (!strcmp (t(), str));
}

inline bool operator != (Token& t, char* str) {
  return (strcmp (t(), str));
}

//==================================================================
//		class header
//		for class STDToken
//==================================================================

//##ModelId=3FBCBCC4001F
class _impexp STDToken : public Token {
  public:
    // constructor
	//##ModelId=3FBCBCC40021
    STDToken();

    // destructor
	//##ModelId=3FBCBCC4002E
    virtual ~STDToken ();

  protected:

  private:
	//##ModelId=3FBCBCC40030
    STDToken (const STDToken&);
	//##ModelId=3FBCBCC40032
    STDToken& operator = (const STDToken&);

};

//==================================================================
//		class header
//		for class VRMLToken
//==================================================================

//##ModelId=3FBCBCC4003E
class _impexp VRMLToken : public Token {
  public:
    // constructor
	//##ModelId=3FBCBCC4004F
    VRMLToken ();

    // destructor
	//##ModelId=3FBCBCC40050
    virtual ~VRMLToken ();

    // parse next Token from stream
	//##ModelId=3FBCBCC40052
    virtual streampos nextToken (InputFile&);

  protected:

  private:
	//##ModelId=3FBCBCC4005F
    VRMLToken (const VRMLToken&);
	//##ModelId=3FBCBCC40061
    VRMLToken& operator = (const VRMLToken&);

};

#endif // _Token_H




