Wexus2 0.20
|
00001 00002 /* 00003 * Copyright (c) 2011 Aleksander B. Demko 00004 * This source code is distributed under the MIT license. 00005 * See the accompanying file LICENSE.MIT.txt for details. 00006 */ 00007 00008 #ifndef __INCLUDED_WEXUS_MODELTOKEN_H__ 00009 #define __INCLUDED_WEXUS_MODELTOKEN_H__ 00010 00011 #include <QByteArray> 00012 #include <QString> 00013 00014 namespace wexus 00015 { 00016 class ModelToken; 00017 class LiteralModelToken; 00018 class FieldModelToken; 00019 } 00020 00021 /** 00022 * The base class of all model tokens. 00023 * 00024 * @author Aleksander Demko 00025 */ 00026 class wexus::ModelToken 00027 { 00028 public: 00029 /** 00030 * Constructor. 00031 * 00032 * @param typ the type of token, one of 'S' (fields section) 'F' (fields) or 'L' (literal) 00033 * @param lit the literal code/byte stream 00034 * 00035 * @author Aleksander Demko 00036 */ 00037 ModelToken(char typ); 00038 00039 /// dtor marked virtual 00040 virtual ~ModelToken() { } 00041 00042 char type(void) const { return dm_type; } 00043 00044 private: 00045 char dm_type; // one of ' ' '=' 'L' (literal) 00046 }; 00047 00048 class wexus::LiteralModelToken : public wexus::ModelToken 00049 { 00050 public: 00051 /** 00052 * Constructor. 00053 * 00054 * @param typ the type of token, one of 'S' (fields section) 'F' (fields) or 'L' (literal) 00055 * @param lit the literal code/byte stream 00056 * 00057 * @author Aleksander Demko 00058 */ 00059 LiteralModelToken(char typ, const QByteArray &lit); 00060 00061 const QByteArray &data(void) const { return dm_data; } 00062 QByteArray &data(void) { return dm_data; } 00063 00064 private: 00065 QByteArray dm_data; 00066 }; 00067 00068 class wexus::FieldModelToken : public wexus::ModelToken 00069 { 00070 public: 00071 /** 00072 * Constructor. 00073 * 00074 * @param typ the type of token, one of 'S' (fields section) 'F' (a field) or 'L' (literal) 00075 * @param lit the literal code/byte stream 00076 * 00077 * @author Aleksander Demko 00078 */ 00079 FieldModelToken(char typ, 00080 const QString &fieldName, const QString &fieldType, 00081 const QString &fieldValidationExpr, 00082 const QString &fieldInitLit); 00083 00084 const QString & fieldName(void) const { return dm_fieldName; } 00085 const QString & fieldType(void) const { return dm_fieldType; } 00086 const QString & fieldValidationExpr(void) const { return dm_fieldValidationExpr; } 00087 const QString & fieldInitLit(void) const { return dm_fieldInitLit; } 00088 00089 private: 00090 QString dm_fieldName, dm_fieldType, dm_fieldValidationExpr, dm_fieldInitLit; 00091 }; 00092 00093 #endif 00094