Core: Buffer::Get and ::IsEmpty

git-svn-id: svn://ultimatepp.org/upp/trunk@10991 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-04-09 13:16:36 +00:00
parent c9bb56577b
commit 812df4cdfc
2 changed files with 11 additions and 12 deletions

View file

@ -45,11 +45,14 @@ public:
operator const T*() const { return ptr; }
T *operator~() { return ptr; }
const T *operator~() const { return ptr; }
T *Get() { return ptr; }
const T *Get() const { return ptr; }
void Alloc(size_t size) { Clear(); ptr = new T[size]; }
void Alloc(size_t size, const T& in) { Clear(); ptr = new T[size]; Fill(ptr, ptr + size, in); }
void Clear() { if(ptr) delete[] ptr; ptr = NULL; }
bool IsEmpty() const { return ptr == NULL; }
Buffer() { ptr = NULL; }
Buffer(size_t size) { ptr = new T[size]; }

View file

@ -77,22 +77,13 @@ ick`_]_[_^Buffer^ Buffer][@(0.0.255) `&]_[*@3 v])&]
[s3;%- &]
[s4;%- &]
[s5;:Buffer`:`:operator T`*`(`):%- [* operator_T`*]()&]
[s2; Returns a pointer to the first element of the Buffer or NULL
if the Buffer is empty.&]
[s3;%- &]
[s4;%- &]
[s5;:Buffer`:`:operator const T`*`(`)const:%- [* operator_const_T`*]()_[@(0.0.255) const]&]
[s2; Returns a pointer to the first element of the Buffer or NULL
if the Buffer is empty.&]
[s3;%- &]
[s4;%- &]
[s5;:Buffer`:`:operator`~`(`):%- [*@4 T]_`*[* operator`~]()&]
[s2; Returns a pointer to the first element of the Buffer or NULL
if the Buffer is empty.&]
[s3;%- &]
[s4;%- &]
[s5;:Buffer`:`:operator`~`(`)const:%- [@(0.0.255) const]_[*@4 T]_`*[* operator`~]()_[@(0.0.255) c
onst]&]
[s5;:Upp`:`:Buffer`:`:Get`(`):%- [*@4 T]_`*[* Get]()&]
[s5;:Upp`:`:Buffer`:`:Get`(`)const:%- [@(0.0.255) const]_[*@4 T]_`*[* Get]()_[@(0.0.255) cons
t]&]
[s2; Returns a pointer to the first element of the Buffer or NULL
if the Buffer is empty.&]
[s3;%- &]
@ -115,4 +106,9 @@ are lost.&]
[s2; Clears the buffer to the same state as default constructor.
All current elements are destroyed.&]
[s3; &]
[s4;%- &]
[s5;:Upp`:`:Buffer`:`:IsEmpty`(`)const:%- [@(0.0.255) bool]_[* IsEmpty]()_[@(0.0.255) const
]&]
[s2; Returns true if Buffer is empty.&]
[s3;%- &]
[s0; ]]