#ifndef _COLDATA_H_ #define _COLDATA_H_ /** @file ColData.h @brief Header file for the ColData class. @date $Date$ @version $Rev$ @author - Lance Deaver @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @see gatsDBpp::ColData @bug None known @todo Add EXPORT #define so windows users can build DLLs $Id$ */ #include #include #include #include #include namespace gatsDBpp { class ColData; //forward declaration /** * @relates gatsDBpp::ColData * @brief Overloaded std::ostream operator<< that works on ColData objects. */ std::ostream& operator<<(std::ostream& os, const ColData& C); class ColData { public: /** * @brief The default constructor for the ColData class */ explicit ColData(const char* cc=NULL, const unsigned long len=0, const bool quotedata=false) ; /** * @brief Construct a ColData from std::string. */ explicit ColData(const std::string& s, const bool quotedata=true); /** * @brief Construct a ColData from an int. */ explicit ColData(const int i); /** * @brief Construct a ColData from a long int. */ explicit ColData(const long int l); /** * @brief Construct a ColData from a short int. */ explicit ColData(const short int s); /** * @brief Construct a ColData from an unsigned int. */ explicit ColData(const unsigned int iu); /** * @brief Construct a ColData from an unsigned long int. */ explicit ColData(const unsigned long int il); /** * @brief Construct a ColData from an unsigned short int. */ explicit ColData(const unsigned short int ius); /** * @brief Construct a ColData from a long long int. */ explicit ColData(const long long int ll); /** * @brief Construct a ColData from an unsigned long long int. */ explicit ColData(const unsigned long long int ull); /** * @brief Construct a ColData from a float. */ explicit ColData(const float f, const unsigned int sigdigits=std::numeric_limits::digits10); /** * @brief Construct a ColData from a double. */ explicit ColData(const double d, const unsigned int sigdigits=std::numeric_limits::digits10); /** * @brief Construct a ColData from a long double. */ explicit ColData(const long double d, const unsigned int sigdigits=std::numeric_limits::digits10); /** * @brief ColData destructor. */ virtual ~ColData(); /** * @brief Return the length (bytes) of the data in the ColData. */ unsigned long int Length() const ; /** * @brief Return bool indicating if the data in ColData has a 0 length. */ bool isEmpty() const ; /** * @brief Return logical indicating if ColData is NULL. */ bool isNull() const ; /** * @brief A boolean which indicates if the data in ColData needs to be quoted and escaped before used in an SQL string. */ bool needsQuote() const ; /** * @brief Return the data as std::string. */ std::string asString() const; /** * @brief Return the data as double. */ double asDouble(const bool failIfLeftoverChars=true ) const; /** * @brief Return the data as float. */ float asFloat(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as long. */ long int asLong(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as unsigned long. */ unsigned long int asUlong(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as int. */ int asInt(const bool failIfLeftoverChars=true) const; /** * @brief Return the data as unsigned int. */ unsigned int asUint(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as short int. */ short int asShort(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as unsigned short int. */ unsigned short int asUshort(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as a NULL terminated char string. */ const char* asC_str() const; /** * @brief Return the data as long double. */ long double asLongDouble(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as long long int. */ long long int asLongLong(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as unsigned long long int. */ unsigned long long int asUlongLong(const bool failIfLeftoverChars=true) const ; /** * @brief Return the data as std::vector. */ std::vector asVecDouble() const ; /** * @brief Return the data as std::vector. */ std::vector asVecLong() const ; /** * @brief Return the data as std::vector. */ std::vector asVecInt() const ; /** * @brief Return the data as std::vector. */ std::vector asVecFloat() const ; /** * @brief Return the data as std::vector. */ std::vector asVecUlong() const ; /** * @brief Return the data as std::vector. */ std::vector asVecUint() const ; /** * @brief Return the data as std::vector. */ std::vector asVecShort() const ; /** * @brief Return the data as std::vector. */ std::vector asVecUshort() const ; /** * @brief Return the data as std::vector. */ std::vector asVecLongDouble() const ; /** * @brief Return the data as std::vector. */ std::vector asVecLongLong() const ; /** * @brief Return the data as std::vector. */ std::vector asVecUlongLong() const ; protected: bool _null, _quote; unsigned long int _length; boost::shared_array _data; }; } //end namespace #endif //_COLDATA_H_