Handling comments -- from isql intrepreter
[csql.git] / include / Field.h
blobe5d1d124e600de92ee5a4bdcd35688a9d97d85f1
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #ifndef FIELD_H
17 #define FIELD_H
18 #include<os.h>
19 #include<DataType.h>
20 #include<ErrorType.h>
22 //used by FieldNameList
23 class FieldNameNode
25 public:
26 char fldName[IDENTIFIER_LENGTH];
27 FieldNameNode *next;
31 class FieldDef
33 public:
34 FieldDef()
36 init();
38 void init() {
39 type_ = typeUnknown;
40 length_ = 0;
41 bindVal_ = NULL;
42 isDefault_ = false;
43 isNull_ = false;
45 char fldName_[IDENTIFIER_LENGTH];
46 DataType type_;
47 size_t length_;
48 //currently default value is supported for string and binary
49 //less than length 32 bytes
50 char defaultValueBuf_[DEFAULT_VALUE_BUF_LENGTH];
52 //used only in case of binding fields
53 void *bindVal_;
55 bool isNull_;
56 bool isPrimary_;
57 bool isDefault_;
58 bool isUnique_;
59 //TODO::width and scale
62 class FieldNode
64 public:
65 FieldDef fldDef;
66 FieldNode *next;
70 class FieldIterator
72 public:
73 FieldNode *iter;
74 FieldIterator(FieldNode *ptr) { iter = ptr; }
75 bool hasElement()
77 if (iter == NULL) return false; else return true;
79 FieldDef nextElement()
81 if (iter == NULL) { FieldDef dummyDef; return dummyDef;}
82 FieldNode *node = iter;
83 iter = iter ->next;
84 return node->fldDef;
88 class FieldInfo;
90 //Internal class used to implement the field list information
91 //to create the table
92 class FieldList
94 public:
95 FieldNode *head;
96 FieldList(){ head = NULL;}
98 //TODO::pass by reference instead of value
99 DbRetVal append(FieldDef fDef);
101 DbRetVal remove(const char* fldName);
103 DbRetVal removeAll();
105 DbRetVal updateBindVal(const char *fldName, void *val);
107 int getFieldOffset(const char *fldName);
108 int getFieldOffset(int fldpos);
110 DataType getFieldType(const char *fldName);
112 size_t getFieldLength(const char *fldName);
114 DbRetVal getFieldInfo(const char *fldName, FieldInfo *&info);
116 int getTupleSize();
118 FieldIterator getIterator()
120 FieldIterator iter(head);
121 return iter;
124 #endif