1 #ifndef __ARCHIVES_HPP__ 2 #define __ARCHIVES_HPP__ 16 static int _FindConfigRef(
String const & str,
int offset,
int * length,
String * name );
33 int load(
String const & configFile );
36 bool has(
String const & name )
const {
return _rawParams.find(name) != _rawParams.end(); }
39 String get(
String const & name,
bool stripslashes =
false,
bool expand = false )
const;
50 void setRaw(
String const & name,
String const & value );
59 bool del(
String const & name );
86 size_t load(
String const & settingsFile );
92 Mixed & update(
String const & multiname,
String const & updateExprStr = $T(
"") );
100 Mixed const & operator [] (
String const & name )
const;
105 bool has(
String const & name )
const;
114 Mixed const & val()
const;
119 Mixed const & expr()
const;
127 Mixed _collectionVal;
128 Mixed _collectionExpr;
145 void writeRecord(
Mixed const & record );
159 Mixed const & operator [] (
int iRow )
const {
return _records[iRow]; }
161 Mixed const & operator () (
int iRow,
String const & name )
const {
return _records[iRow][ _columns[name] ]; }
163 size_t getCount()
const {
return _records.getCount(); }
170 void read(
String const & content,
bool hasColumnHeaders =
false );
204 this->_fileEncoding = fileEncoding;
210 return this->_fileEncoding;
216 this->_contentEncoding = contentEncoding;
222 return this->_contentEncoding;
228 this->_mbsEncoding = mbsEncoding;
234 return this->_mbsEncoding;
256 this->load( f->
buffer(
true), isConvert, targetEncoding, mbsEncoding );
267 this->setMultiByteEncoding(mbsEncoding);
270 this->_recognizeEncode( content, &i );
275 template <
typename _ChTy >
278 this->write(
winux::Buffer( (
void *)content.c_str(), content.length() *
sizeof(_ChTy),
true ) );
285 template <
typename _ChTy >
288 this->write(
winux::Buffer( (
void *)content.c_str(), content.length() *
sizeof(_ChTy),
true ), encoding );
294 this->_pureContent.append(content);
303 this->setContentEncoding(encoding);
304 this->_pureContent.append(content);
310 this->save( output, this->_fileEncoding );
316 this->save( f, this->_fileEncoding );
322 this->save( filePath, this->_fileEncoding );
331 this->saveEx( this->_pureContent, this->_contentEncoding, output, fileEncoding );
340 this->saveEx( this->_pureContent, this->_contentEncoding, f, fileEncoding );
349 this->saveEx( this->_pureContent, this->_contentEncoding, filePath, fileEncoding );
369 this->saveEx( content, encoding, &buf, fileEncoding );
382 this->saveEx( content, encoding, &file, fileEncoding );
386 template <
typename _ChTy >
389 return this->_pureContent.toString<_ChTy>();
395 this->_pureContent.free();
402 void _recognizeEncode(
winux::Buffer const & content,
size_t * pI );
413 #endif // __ARCHIVES_HPP__ XString< char > AnsiString
void * getBuf() const
暴露缓冲区指针
Mixed const mxNull
Mixed(MT_NULL)常量对象
winux::AnsiString const & getMultiByteEncoding() const
获取多字节编码
Mixed & getColumnHeaders()
获取所有列标头
void save(winux::GrowBuffer *output)
保存本对象的内容到缓冲区
size_t getCount() const
获取读取到的记录数
void saveEx(winux::Buffer const &content, winux::AnsiString const &encoding, winux::IFile *f, FileEncoding fileEncoding)
保存内容到文件对象
std::map< String, String > StringStringMap
winux::XString< _ChTy > toString() const
转成指定字符的字符串
void load(winux::Buffer const &content, bool isConvert, winux::AnsiString const &targetEncoding="", winux::AnsiString const &mbsEncoding="")
载入指定内容
size_t getSize() const
获取数据大小
virtual size_t write(void const *data, size_t size)
写数据,返回写入的字节数
void save(winux::String const &filePath)
保存本对象的内容到文件
void saveEx(winux::Buffer const &content, winux::AnsiString const &encoding, winux::String const &filePath, FileEncoding fileEncoding)
保存内容到文件
void save(winux::String const &filePath, FileEncoding fileEncoding)
保存本对象的内容到文件
void write(winux::XString< _ChTy > const &content, winux::AnsiString const &encoding)
写入字符串内容
void save(winux::GrowBuffer *output, FileEncoding fileEncoding)
保存本对象的内容到缓冲区
void setContentEncoding(winux::AnsiString const &contentEncoding)
设置内容编码。当给文本文档写入内容时,内容默认是什么编码,用这个函数指定。
std::basic_string< _ChTy, std::char_traits< _ChTy >, std::allocator< _ChTy > > XString
缓冲区,表示内存中一块二进制数据(利用malloc/realloc进行内存分配)
void write(winux::Buffer const &content, winux::AnsiString const &encoding)
写入内容
TextArchive(FileEncoding fileEncoding=feMultiByte, winux::AnsiString const &contentEncoding="", winux::AnsiString const &mbsEncoding="")
构造函数1
void setMultiByteEncoding(winux::AnsiString const &mbsEncoding)
设置多字节编码。当文件编码为多字节时,这个参数指示是哪一个多字节编码。
void load(winux::IFile *f, bool isConvert, winux::AnsiString const &targetEncoding="", winux::AnsiString const &mbsEncoding="")
载入文本文件
virtual Buffer buffer(bool isPeek=true)
读取整个文件内容,返回缓冲区
void write(winux::Buffer const &content)
写入内容
Mixed & getRecords()
获取所有记录的引用,可直接操作
void save(winux::IFile *f, FileEncoding fileEncoding)
保存本对象的内容到文件
文本文档类。可载入文本文件自动识别BOM文件编码,转换为指定编码。
Plain成员隐藏(By plain block)
winux::AnsiString const & getContentEncoding() const
获取内容编码
void setFileEncoding(FileEncoding fileEncoding)
设置文件编码。文件编码当载入文本文件时会自动设置。但如果一开始就只是写文本文档,还是需要手动设置文件...
FileEncoding const & getFileEncoding() const
获取文件编码
void write(winux::XString< _ChTy > const &content)
写入字符串内容
void save(winux::IFile *f)
保存本对象的内容到文件
XStringArray< tchar > StringArray
void load(winux::String const &filePath, bool isConvert, winux::AnsiString const &targetEncoding="", winux::AnsiString const &mbsEncoding="")
载入文本文件
Buffer FileGetContentsEx(String const &filename, bool textMode)
载入文件内容为一个Buffer,textMode表示是否为文本模式