1 #ifndef DBAPI_DRIVER___TYPES__HPP
2 #define DBAPI_DRIVER___TYPES__HPP
97 template <
typename TChar>
115 operator const value_type*(void)
const;
133 string::size_type
size = string::npos,
139 wstring::size_type
size = wstring::npos);
150 if (!(GetAvailableValueType() &
eString)) {
160 if (!(GetAvailableValueType() & eChar)) {
161 x_MakeString(str_enc);
167 operator const wstring&(void)
const
169 if (!(GetAvailableValueType() & eWString)) {
179 if (!(GetAvailableValueType() & eWChar)) {
180 x_MakeWString(str_enc);
191 if (!(GetAvailableValueType() &
eString)) {
192 x_MakeString(str_enc);
199 if (!(GetAvailableValueType() & eUTF8String)) {
200 x_MakeUTF8String(str_enc);
207 if (!(GetAvailableValueType() & eUCS2LEString)) {
208 x_MakeUCS2LEString(str_enc);
211 return m_UCS2LEString;
216 if (!(GetAvailableValueType() & eWString)) {
217 x_MakeWString(str_enc);
227 return AsUTF8(from_enc);
230 return AsLatin1(from_enc);
233 size_t GetSymbolNum(
void)
const;
237 void Assign(
const char*
str,
238 string::size_type
size = string::npos,
240 void Assign(
const string&
str,
243 void Assign(
const wchar_t*
str,
244 wstring::size_type
size = wstring::npos);
245 void Assign(
const wstring&
str);
251 return m_AvailableValueType;
261 void x_CalculateEncoding(
EEncoding str_enc)
const;
304 virtual void AssignNULL();
316 static const char* GetTypeName(
EDB_Type db_type,
317 bool throw_on_unknown =
true);
323 string GetLogString(
void)
const;
326 void SetNULL(
bool flag =
true) { m_Null = flag; }
374 void*
BindVal()
const {
return (
void*) &m_Val; }
378 virtual void AssignValue(
const CDB_Object& v);
401 void*
BindVal()
const {
return (
void*) &m_Val; }
405 virtual void AssignValue(
const CDB_Object& v);
428 void*
BindVal()
const {
return (
void*) &m_Val; }
432 virtual void AssignValue(
const CDB_Object& v);
455 void*
BindVal()
const {
return (
void*) &m_Val; }
460 virtual void AssignValue(
const CDB_Object& v);
476 string::size_type
size = string::npos,
479 string::size_type
size = string::npos,
482 TStringUCS2::size_type
size = TStringUCS2::npos);
501 operator const string&(void)
const
507 #if defined(HAVE_WSTRING)
511 return IsNULL() ?
kEmptyWStr : m_WString->AsUnicode(enc);
519 return IsNULL() ?
kEmptyStr : x_GetWString();
524 return IsNULL() ? 0 : m_WString->GetSymbolNum();
529 return IsNULL() ?
NULL : x_GetWString().data();
534 return IsNULL() ?
NULL : x_GetWString().c_str();
537 const char*
Value(
void)
const {
return AsCString(); }
542 void Assign(
const char* s,
543 string::size_type
size = string::npos,
545 void Assign(
const string& s,
546 string::size_type
size = string::npos,
551 TStringUCS2::size_type
size = TStringUCS2::npos);
558 bool convert_raw_bytes =
false)
const;
609 virtual void AssignValue(
const CDB_Object& v);
639 void SetValue(
const char*
str,
650 virtual void AssignValue(
const CDB_Object& v);
686 void SetValue(
const char*
str,
693 size_t Size()
const {
return IsNULL() ? 0 : m_Size; }
700 virtual void AssignValue(
const CDB_Object& v);
718 void SetValue(
const void* v,
size_t l);
724 {
return IsNULL() ?
NULL : (
void*) m_Value->GetData().data(); }
727 {
return IsNULL() ? 0 : m_Value->GetData().size(); }
732 virtual void AssignValue(
const CDB_Object& v);
746 CDB_Binary(
size_t s,
const void* v,
size_t v_size);
751 void SetValue(
const void* v,
size_t v_size);
757 {
return IsNULL() ?
NULL : (
void*) m_Value->GetData().data(); }
760 {
return IsNULL() ? 0 : m_Value->GetData().size(); }
766 virtual void AssignValue(
const CDB_Object& v);
787 void SetValue(
const void* v,
size_t v_size);
793 {
return IsNULL() ?
NULL : (
void*) m_Value->GetData().data(); }
796 {
return IsNULL() ? 0 : m_Value->GetData().size(); }
803 virtual void AssignValue(
const CDB_Object& v);
825 float Value()
const {
return IsNULL() ? 0 : m_Val; }
826 void*
BindVal()
const {
return (
void*) &m_Val; }
830 virtual void AssignValue(
const CDB_Object& v);
850 double Value()
const {
return IsNULL() ? 0 : m_Val; }
851 void*
BindVal()
const {
return (
void*) &m_Val; }
855 virtual void AssignValue(
const CDB_Object& v);
871 virtual void AssignNULL();
875 virtual size_t Read (
void* buff,
size_t nof_bytes);
876 virtual size_t Peek (
void* buff,
size_t nof_bytes)
const;
877 virtual size_t PeekAt (
void* buff,
size_t start,
size_t nof_bytes)
const;
878 virtual size_t Append (
const void* buff,
size_t nof_bytes);
880 virtual bool MoveTo (
size_t byte_number);
883 virtual size_t Size()
const;
884 virtual void AssignValue(
const CDB_Object& v);
893 size_t x_Append(
const void* buff,
size_t nof_bytes);
895 size_t x_Append(
const TStringUCS2& s,
size_t l = TStringUCS2::npos);
957 virtual size_t Append(
const void* buff,
size_t nof_bytes);
987 virtual size_t Append(
const void* buff,
size_t nof_bytes);
990 virtual size_t Append(
const TStringUCS2& s,
size_t l = TStringUCS2::npos);
994 {
Truncate(); Append(s, enc);
return *
this; }
997 {
Truncate(); Append(s, enc);
return *
this; }
1002 size_t l = TStringUCS2::npos)
1003 {
Truncate(); Append(s,
l);
return *
this; }
1031 Uint2 GetDays(
void)
const;
1032 Uint2 GetMinutes(
void)
const;
1034 virtual EDB_Type GetType(
void)
const;
1036 virtual void AssignValue(
const CDB_Object& v);
1062 Int4 GetDays(
void)
const;
1063 Int4 Get300Secs(
void)
const;
1065 virtual EDB_Type GetType(
void)
const;
1067 virtual void AssignValue(
const CDB_Object& v);
1105 {
return Assign(
t); }
1110 {
return m_Offset; }
1112 {
return m_SQLType; }
1113 const char* GetSQLTypeName(ESyntax syntax);
1115 virtual EDB_Type GetType(
void)
const;
1117 virtual void AssignValue(
const CDB_Object& v);
1120 ESQLType sql_type = eDateTime,
1122 static pair<ESyntax, ESQLType> Identify(
const CTempString& s);
1145 int Value()
const {
return IsNULL() ? 0 : (
int) m_Val; }
1150 virtual void AssignValue(
const CDB_Object& v);
1165 const unsigned char*
arr);
1167 const unsigned char*
arr);
1174 const unsigned char*
arr);
1176 bool is_negative,
const unsigned char*
arr);
1181 string Value()
const;
1193 const unsigned char*
RawData()
const {
return m_Body; }
1197 virtual void AssignValue(
const CDB_Object& v);
1200 void x_MakeFromString(
unsigned int precision,
1205 unsigned char m_Body[33];
int TOffset
Basic data type for offsets into a sequence.
Convenience extension of basic_string, supporting implicit conversion to const TChar* in most situati...
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
static vector< string > arr
static const char * str(char *buf, int n)
static bool IsBlobType(EDB_Type db_type)
CObjectFor< string > TValue
basic_string< TChar > TBasicString
const void * Value() const
CGenericSqlString< char > CSqlString
CGenericSqlString(const value_type *data)
static EBlobType GetBlobType(EDB_Type db_type)
void SetBulkInsertionEnc(EBulkEnc e)
const TOffset & GetOffset(void) const
TBasicString::size_type size_type
const unsigned char * RawData() const
TStringUCS2 m_UCS2LEString
EBulkEnc GetEncoding(void) const
typedef NCBI_PARAM_TYPE(dbapi, max_logged_param_length) TDbapi_MaxLoggedParamLength
TBasicString::value_type value_type
size_type byte_count(void) const
const char * Value(void) const
const void * Value() const
const string & ConvertTo(EEncoding to_enc, EEncoding from_enc=eEncoding_Unknown) const
const char * AsCString(void) const
CGenericSqlString(const TBasicString &s)
EBulkEnc GetEncoding(void) const
unsigned max_logged_param_length
virtual EDB_Type GetType() const =0
CDB_VarCharMax & SetValue(const TStringUCS2 &s, size_t l=TStringUCS2::npos)
const void * Data() const
const TStringUCS2 & AsUCS2_LE(EEncoding str_enc=eEncoding_Unknown) const
const wstring & AsWString(EEncoding enc) const
const CTime & GetCTime(void) const
CGenericSqlString(const value_type *data, size_type len)
const string & AsUTF8(EEncoding str_enc=eEncoding_Unknown) const
const wstring & AsUnicode(EEncoding str_enc=eEncoding_Unknown) const
const wchar_t * AsCWString(EEncoding str_enc=eEncoding_Unknown) const
CObjectFor< string > TValue
CGenericSqlString< wchar_t > CWSqlString
CNullable< short > TOffset
offset in minutes from GMT, if known
virtual void AssignValue(const CDB_Object &v)=0
int GetAvailableValueType(void) const
CObjectFor< string > TValue
ESQLType GetSQLType(void) const
virtual CDB_Object * ShallowClone() const
const string & AsString(void) const
void SetValue(const void *v, size_t l)
void SetNULL(bool flag=true)
EBulkEnc m_BulkInsertionEnc
EEncoding m_StringEncoding
CDB_VarCharMax & SetValue(const char *s, size_t l, EEncoding enc=eEncoding_Unknown)
const void * Data() const
virtual CDB_Object * Clone() const =0
CDB_VarCharMax & SetValue(const char *s, EEncoding enc=eEncoding_Unknown)
EBulkEnc GetBulkInsertionEnc(void) const
const char * AsCString(EEncoding str_enc=eEncoding_Unknown) const
const char * Data(void) const
CDB_VarCharMax & SetValue(const string &s, EEncoding enc=eEncoding_Unknown)
const string & AsLatin1(EEncoding str_enc=eEncoding_Unknown) const
const void * Data() const
const string & x_GetWString() const
CRef< CWString > m_WString
const void * Value() const
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
CObject & operator=(const CObject &src) THROWS_NONE
Assignment operator.
#define NCBI_PARAM_DECL_EXPORT(expname, type, section, name)
Same as NCBI_PARAM_DECL but with export specifier (e.g.
uint8_t Uint1
1-byte (8-bit) unsigned integer
int16_t Int2
2-byte (16-bit) signed integer
int32_t Int4
4-byte (32-bit) signed integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
basic_string< TCharUCS2 > TStringUCS2
Type for string in UCS-2 encoding.
EInitMode
Which initial value to use for time.
CTime Truncate(const CTime &t)
@ eEmpty
Use "empty" time.
unsigned int
A callback function used to compare two keys in a database.
static void text(MDB_val *v)
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Defines: CTimeFormat - storage class for time format.
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Database format for time where day and time is signed 32 bit.
Database format for time where day and time is unsigned 16 bit.