Files
envi-code/SourceCode/Code2026/tg_shs/inc/dbf/TDbfString.h
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

68 lines
2.2 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2010, Beijing Tangent Software Co. Ltd.
// = FileName : TDbfString 类
// = Version : ver1.0
// = Author : gjm
// = CreateDate : 2010-07-06
// = Description: 以std::string实现,内部数据只能是char。目的是与dbf类相匹配。
// = Maintainers:
//-----------------------------------------------------------------------------+
#include <string>
#if !defined(_TDBFSTRING_H__INCLUDED_)
#define _TDBFSTRING_H__INCLUDED_
class CTDbfString
{
public:
CTDbfString():m_str(""){};
CTDbfString(const TCHAR *pszStr);
CTDbfString(const std::string &str);
CTDbfString(const CString &str);
CTDbfString(const std::wstring &str);
CTDbfString(const CTDbfString &str);
#if defined(UNICODE) || defined(_UNICODE)
CTDbfString(const char *pszStr):m_str(pszStr){}
CTDbfString& operator = (const char *pszstr){m_str = pszstr;return *this;}
#else
CTDbfString(const wchar_t *pszStr);
CTDbfString& operator = (const wchar_t *pszstr);
#endif
~CTDbfString(){};
CTDbfString& operator = (const CTDbfString &str);
CTDbfString& operator = (const CString &str);
CTDbfString& operator = (const std::string &str);
CTDbfString& operator = (const std::wstring &str);
CTDbfString& operator = (const TCHAR *pszstr);
bool operator > (const CTDbfString &str){return (m_str > str.toString());}
bool operator < (const CTDbfString &str){return (m_str < str.toString());}
bool operator == (const CTDbfString &str){return (m_str == str.toString());}
bool operator != (const CTDbfString &str){return (m_str != str.toString());}
const char* toLPCSTR (){return m_str.c_str();}
CString toCString (){return CString(m_str.c_str());}
std::string toString () const {return m_str;}
BSTR toBSTR (){return (toCString().AllocSysString());}
size_t GetLength (){return m_str.size();}
//modify by xlc on 101015 vc6.0无clear函数
//void Empty (){m_str.clear();}
void Empty ()
{
#if ADS == 15
m_str.erase(m_str.begin(),m_str.end());
#else
m_str.clear();
#endif
}
bool IsEmpty (){return m_str.empty();}
char GetAt (size_t t) {return m_str.at(t);}
private:
std::string m_str;
};
#endif