38 #include <rdbxx/RDBErr.h> 57 enum Just { LEFT=
'<', RIGHT=
'>' };
60 enum Type { MONTH=
'M', NUMERIC=
'N', STRING=
'S' };
62 enum Err { NOERR=0, LOSTPRECISION=EDOM, NONNUMERIC=EINVAL, OUTOFRANGE=ERANGE, NODATA=ENODATA };
63 enum Status { CMOG=0x01, CEOG=0x02, CBOG=0x04 };
69 RDBColumn(
const std::string& name=
"",
const std::string& def=
"" );
91 virtual void rewind(
void ) = 0;
109 void setName(
const std::string& name );
112 void setDef(
const std::string& def );
120 void setDesc(
const std::string& desc );
128 virtual bool setData(
const double& data ) = 0;
130 virtual bool setData(
const long& data ) = 0;
132 virtual bool setData(
const std::string& data ) = 0;
137 virtual void mapData(
double data[],
const size_t nelems=1 );
140 virtual void mapData(
long data[],
const size_t nelems=1 );
142 virtual void mapData( std::string data[],
const size_t nelems=1 );
147 std::string
getName(
void )
const;
150 std::string
getDef(
void );
160 std::string
getDesc(
void )
const;
166 char*
getErr(
void )
const;
170 virtual void*
getData(
void ) = 0;
172 virtual bool getData(
double& data ) = 0;
174 virtual bool getData(
long& data ) = 0;
176 virtual bool getData( std::string& data ) = 0;
187 void convert(
const double& idata,
double& odata );
189 void convert(
const double& idata,
long& odata );
191 void convert(
const double& idata, std::string& odata );
193 void convert(
const long& idata,
double& odata );
195 void convert(
const long& idata,
long& odata );
197 void convert(
const long& idata, std::string& odata );
199 void convert(
const std::string& idata,
double& odata );
201 void convert(
const std::string& idata,
long& odata );
203 void convert(
const std::string& idata, std::string& odata );
206 virtual std::istream&
read( std::istream& is ) = 0;
208 virtual std::istream&
extract( std::istream& is,
double& data );
210 virtual std::istream&
extract( std::istream& is,
long& data );
212 virtual std::istream&
extract( std::istream& is, std::string& data );
214 virtual std::ostream&
write( std::ostream& os )
const = 0;
216 virtual std::ostream&
insert( std::ostream& os,
double& data )
const;
218 virtual std::ostream&
insert( std::ostream& os,
long& data )
const;
220 virtual std::ostream&
insert( std::ostream& os, std::string& data )
const;
std::string getDef(void)
Returns the definition.
char * getErr(void) const
Returns a brief description of the error condition.
virtual void rewind(void)=0
Rewinds index to the RDBColumn's data elements.
void setName(const std::string &name)
Sets the name.
bool _throw
State of the exception throwing behavior.
void setPrecision(const int precision)
Sets the precision for numeric output and numeric to string conversion.
RDBColumn & operator=(const RDBColumn &col)
Copies RDBColumn object.
Just
Acceptable column justifications.
void setDef(const std::string &def)
Sets the definition.
virtual void setGroupValue(void)=0
Sets the group value to the current data value.
void setErrNo(const int no=0)
Sets the error status.
std::stringstream _strstrm
Used for numeric to string conversion.
bool _changed
Indicates state for the definition field.
friend std::ostream & operator<<(std::ostream &os, const RDBColumn &col)
Write column to output stream.
void setWidth(const long width)
Sets the width.
void setJust(const RDBColumn::Just just)
Sets the justification.
virtual std::string getDataString(void)=0
Returns the value of the current data element, converting if necessary.
std::string _def
Definition.
bool _initgroup
Group been initialized.
virtual void * getData(void)=0
Returns a pointer to the current data element.
std::string getName(void) const
Returns the name.
void setType(const RDBColumn::Type type)
Sets the type.
Err
Possible error conditions.
std::string getDesc(void) const
Returns the description.
int getErrNo(void) const
Returns the error status.
virtual void setGroup(bool group)
Turn on/off group tracking for this column object.
bool getGroup(void) const
Returns group status, RBOG if at beginning of a group, REOG if at ned of a group, or REOL if in the m...
RDBColumn::Type _type
Data type.
RDBColumn::Just _just
Justification.
RDBColumn::Type getType(void) const
Returns the type.
int _precision
Precision used for stream output or numeric to std::string conversion.
void convert(const double &idata, double &odata)
Used to converted data based on user requests.
virtual void mapData(double data[], const size_t nelems=1)
Maps data to user-supplied memory, if possible.
void setDesc(const std::string &desc)
Sets the description.
Type
Acceptable column types.
virtual double getDataDouble(void)=0
Returns the value of the current data element, converting if necessary.
virtual bool setData(const double &data)=0
Sets the data value, converting as necessary.
RDBColumn(const std::string &name="", const std::string &def="")
Assigns name and definition to RDBColumn object.
std::string _desc
Description.
virtual std::istream & extract(std::istream &is, double &data)
Overridden in the subclass of this datatype.
virtual std::istream & read(std::istream &is)=0
Called by the stream insertion operator.
long getWidth(void) const
Returns the width.
bool _group
This is a group column.
void setThrow(const bool t=true)
Sets the excpeption throwing behavior.
bool getThrow(void) const
Returns the state of the exception throwing behavior.
virtual ~RDBColumn(void)
Deletes resources allocated by RDBColumn object.
friend std::istream & operator>>(std::istream &is, RDBColumn &col)
Read column from input stream.
virtual std::ostream & insert(std::ostream &os, double &data) const
Overridden in the subclass of this datatype.
virtual void advanceIdx(void)=0
Increments index to the RDBColumn's data elements.
virtual int newGroup(void)=0
Returns the group status of this column object.
RDBColumn::Just getJust(void) const
Returns the justification.
virtual long getDataLong(void)=0
Returns the value of the current data element, converting if necessary.
int getPrecision(void) const
Returns the precision.
virtual std::ostream & write(std::ostream &os) const =0
Called by the stream extraction operator.
Provides interface for general column related methods.