Though select fails, it return the tuple. This is because curTuple_ is not set in...
[csql.git] / include / Field.h
blobceb56e71b61b41dd028dd98a194792be234ccc34
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 type_ = typeUnknown;
37 length_ = 0;
38 bindVal_ = NULL;
40 char fldName_[IDENTIFIER_LENGTH];
41 DataType type_;
42 size_t length_;
43 //currently default value is supported for string and binary
44 //less than length 32 bytes
45 char defaultValueBuf_[DEFAULT_VALUE_BUF_LENGTH];
47 //used only in case of binding fields
48 void *bindVal_;
50 bool isNull_;
51 bool isPrimary_;
52 bool isDefault_;
53 bool isUnique_;
54 //TODO::width and scale
57 class FieldNode
59 public:
60 FieldDef fldDef;
61 FieldNode *next;
65 class FieldIterator
67 public:
68 FieldNode *iter;
69 FieldIterator(FieldNode *ptr) { iter = ptr; }
70 bool hasElement()
72 if (iter == NULL) return false; else return true;
74 FieldDef nextElement()
76 if (iter == NULL) { FieldDef dummyDef; return dummyDef;}
77 FieldNode *node = iter;
78 iter = iter ->next;
79 return node->fldDef;
83 class FieldInfo;
85 //Internal class used to implement the field list information
86 //to create the table
87 class FieldList
89 public:
90 FieldNode *head;
91 FieldList(){ head = NULL;}
93 //TODO::pass by reference instead of value
94 DbRetVal append(FieldDef fDef);
96 DbRetVal remove(const char* fldName);
98 DbRetVal removeAll();
100 DbRetVal updateBindVal(const char *fldName, void *val);
102 int getFieldOffset(const char *fldName);
103 int getFieldOffset(int fldpos);
105 DataType getFieldType(const char *fldName);
107 size_t getFieldLength(const char *fldName);
109 DbRetVal getFieldInfo(const char *fldName, FieldInfo *&info);
111 int getTupleSize();
113 FieldIterator getIterator()
115 FieldIterator iter(head);
116 return iter;
119 #endif