Removing commented dead code
[csql.git] / include / Field.h
blobfe840b71737affe38df0a3498eca552da8ba0ee8
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 char fldName_[IDENTIFIER_LENGTH];
35 DataType type_;
36 size_t length_;
37 //currently default value is supported for string and binary
38 //less than length 32 bytes
39 char defaultValueBuf_[DEFAULT_VALUE_BUF_LENGTH];
41 //used only in case of binding fields
42 void *bindVal_;
44 bool isNull_;
45 bool isPrimary_;
46 bool isDefault_;
47 //TODO::width and scale
50 class FieldNode
52 public:
53 FieldDef fldDef;
54 FieldNode *next;
58 class FieldIterator
60 public:
61 FieldNode *iter;
62 FieldIterator(FieldNode *ptr) { iter = ptr; }
63 bool hasElement()
65 if (iter == NULL) return false; else return true;
67 FieldDef nextElement()
69 if (iter == NULL) { FieldDef dummyDef; return dummyDef;}
70 FieldNode *node = iter;
71 iter = iter ->next;
72 return node->fldDef;
76 class FieldInfo;
78 //Internal class used to implement the field list information
79 //to create the table
80 class FieldList
82 public:
83 FieldNode *head;
84 FieldList(){ head = NULL;}
86 //TODO::pass by reference instead of value
87 DbRetVal append(FieldDef fDef);
89 DbRetVal remove(const char* fldName);
91 DbRetVal removeAll();
93 DbRetVal updateBindVal(const char *fldName, void *val);
95 int getFieldOffset(const char *fldName);
96 int getFieldOffset(int fldpos);
98 DataType getFieldType(const char *fldName);
100 size_t getFieldLength(const char *fldName);
102 DbRetVal getFieldInfo(const char *fldName, FieldInfo *&info);
104 int getTupleSize();
106 FieldIterator getIterator()
108 FieldIterator iter(head);
109 return iter;
112 #endif