-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfield.hh
77 lines (62 loc) · 1.63 KB
/
field.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* $Id: field.hh,v 2.7 2005/10/20 11:24:12 martin Exp $
* Copyright (c) 2004, 2005, Voidsoft AB
*/
#ifndef VOIDSOFT_TDSPP_FIELD_HH
#define VOIDSOFT_TDSPP_FIELD_HH
#include <string>
#include <vector>
#include <memory>
using namespace std;
/** Field class. AKA column. */
class Field {
friend class Query;
public:
/** Name of the column */
string colname;
/** Constructor */
Field();
/** Constructor */
Field(string name, int size, int datatype_);
/** Destructor */
~Field();
// CS type reference: https://github.com/FreeTDS/freetds/blob/master/include/cspublic.h
/** Return string value of a field. */
string to_str(void);
/** Return integer value of a field. */
long to_int(void);
double to_double();
int64_t to_int64();
/** Return field returned length */
int getDataLength() { return datalength; }
int getDataType() { return datatype; }
private:
char* data;
int datalength;
int datatype;
};
/** Row class */
class Rows {
friend class Query;
public:
/** List of fields type */
typedef vector<Field*> FieldList;
/** List of rows type */
typedef vector<FieldList> RowList;
/** Iterator for list of fields type */
typedef FieldList::iterator FIte;
/** List of rows */
RowList rows;
/** Constructor */
Rows();
/** Destructor */
~Rows();
/** Prints a header for a table to stdout. Prints all column names. */
void printheader();
/** Prints a row to stdout. */
void print();
private:
void clear(void);
int currentrow;
};
#endif /* VOIDSOFT_TDSPP_FIELD_HH */