fixed the PList at current version of CMUtil.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#define HGL_PLIST_INCLUDE
|
#define HGL_PLIST_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/Map.h>
|
#include<hgl/type/Map.h>
|
||||||
#include<hgl/type/StringList.h>
|
#include<hgl/type/LoadStringList.h>
|
||||||
#include<hgl/io/FileOutputStream.h>
|
#include<hgl/io/FileOutputStream.h>
|
||||||
#include<hgl/io/TextOutputStream.h>
|
#include<hgl/io/TextOutputStream.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
@@ -12,12 +12,12 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 属性列表,类似INI的管理类
|
* 属性列表,类似INI的管理类
|
||||||
*/
|
*/
|
||||||
template<typename C> class PList:public Map<BaseString<C>,BaseString<C>> ///属性列表
|
template<typename C> class PList:public Map<String<C>,String<C>> ///属性列表
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using PString=BaseString<C>;
|
using PString=String<C>;
|
||||||
using PStringList=StringList<PString>;
|
using PStringList=StringList<C>;
|
||||||
using PMap=Map<PString,PString>;
|
using PMap=Map<PString,PString>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -79,11 +79,11 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 从文本文件中加载
|
* 从文本文件中加载
|
||||||
*/
|
*/
|
||||||
virtual bool LoadFromTextFile(const OSString &filename) ///<从文件中加载列表
|
virtual bool LoadFromTextFile(const OSString &filename,const CharSet &cs=OSCharSet) ///<从文件中加载列表
|
||||||
{
|
{
|
||||||
PStringList sl;
|
PStringList sl;
|
||||||
|
|
||||||
if(LoadStringListFromTextFile(sl,filename)<=0)
|
if(LoadStringListFromTextFile(sl,filename,cs)<=0)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
ReadData(sl);
|
ReadData(sl);
|
||||||
@@ -95,13 +95,15 @@ namespace hgl
|
|||||||
* 保存到文本文件中
|
* 保存到文本文件中
|
||||||
*/
|
*/
|
||||||
template<ByteOrderMask BOM>
|
template<ByteOrderMask BOM>
|
||||||
bool SaveToTextFile(const OSString &filename,const PString &gap_ch=PString("\t")) ///<保存列表到文件
|
bool SaveToTextFile(const OSString &filename,const C &gap_ch='\t') ///<保存列表到文件
|
||||||
{
|
{
|
||||||
FileOutputStream fos;
|
FileOutputStream fos;
|
||||||
EndianTextOutputStream<BOM> tos(&fos);
|
EndianTextOutputStream<BOM> tos(&fos);
|
||||||
|
|
||||||
if(!fos.CreateTrunc(filename))return(false);
|
if(!fos.CreateTrunc(filename))return(false);
|
||||||
|
|
||||||
|
PString gap_str=PString::charOf(gap_ch);
|
||||||
|
|
||||||
int n=this->data_list.GetCount();
|
int n=this->data_list.GetCount();
|
||||||
|
|
||||||
tos.WriteBOM();
|
tos.WriteBOM();
|
||||||
@@ -110,8 +112,8 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
PString f,s;
|
PString f,s;
|
||||||
|
|
||||||
if(Get(n,f,s))
|
if(GetBySerial(n,f,s))
|
||||||
tos.WriteLine(f+gap_ch+s);
|
tos.WriteLine(f+gap_str+s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
|
Reference in New Issue
Block a user