add new Construct function of BaseString from InputStream
This commit is contained in:
parent
2ba8757dec
commit
f895b3c3b0
@ -26,7 +26,7 @@ namespace hgl
|
|||||||
virtual bool CanSize()const=0; ///<是否可以取得尺寸
|
virtual bool CanSize()const=0; ///<是否可以取得尺寸
|
||||||
|
|
||||||
virtual bool Restart()=0; ///<复位访问指针
|
virtual bool Restart()=0; ///<复位访问指针
|
||||||
virtual int64 Seek(int64,SeekOrigin=SeekOrigin::Begin)=0; ///<移动访问指针
|
virtual int64 Seek(int64,SeekOrigin=SeekOrigin::Begin)=0; ///<移动访问指针
|
||||||
virtual int64 Tell()const=0; ///<返回当前访问位置
|
virtual int64 Tell()const=0; ///<返回当前访问位置
|
||||||
virtual int64 GetSize()const=0; ///<取得流长度
|
virtual int64 GetSize()const=0; ///<取得流长度
|
||||||
virtual int64 Available()const=0; ///<剩下的可以不受阻塞写入的字节数
|
virtual int64 Available()const=0; ///<剩下的可以不受阻塞写入的字节数
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define HGL_TYPE_BASE_STRING_INCLUDE
|
#define HGL_TYPE_BASE_STRING_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/StringInstance.h>
|
#include<hgl/type/StringInstance.h>
|
||||||
|
#include<hgl/io/InputStream.h>
|
||||||
#include<hgl/CompOperator.h>
|
#include<hgl/CompOperator.h>
|
||||||
#include<hgl/type/Smart.h>
|
#include<hgl/type/Smart.h>
|
||||||
|
|
||||||
@ -29,6 +30,24 @@ namespace hgl
|
|||||||
Set(str);
|
Set(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseString(io::InputStream *is,int len=0)
|
||||||
|
{
|
||||||
|
if(len<=0)
|
||||||
|
len=is->Available();
|
||||||
|
|
||||||
|
if(len<=0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
len/=sizeof(T);
|
||||||
|
|
||||||
|
T *str=new T[len+1];
|
||||||
|
|
||||||
|
len=is->Read(str,len*sizeof(T));
|
||||||
|
|
||||||
|
str[len]=0;
|
||||||
|
Set(str,len,true);
|
||||||
|
}
|
||||||
|
|
||||||
explicit BaseString(const T);
|
explicit BaseString(const T);
|
||||||
|
|
||||||
static BaseString<T> charOf(const T &ch)
|
static BaseString<T> charOf(const T &ch)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user