From 812df4cdfc2361d18edd8eae09f6736cb6aa9d7e Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 9 Apr 2017 13:16:36 +0000 Subject: [PATCH] Core: Buffer::Get and ::IsEmpty git-svn-id: svn://ultimatepp.org/upp/trunk@10991 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Vcont.h | 3 +++ uppsrc/Core/src.tpp/Buffer$en-us.tpp | 20 ++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/uppsrc/Core/Vcont.h b/uppsrc/Core/Vcont.h index 674859a70..a2792c5ef 100644 --- a/uppsrc/Core/Vcont.h +++ b/uppsrc/Core/Vcont.h @@ -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]; } diff --git a/uppsrc/Core/src.tpp/Buffer$en-us.tpp b/uppsrc/Core/src.tpp/Buffer$en-us.tpp index b2c5dd1f5..3f25df9bf 100644 --- a/uppsrc/Core/src.tpp/Buffer$en-us.tpp +++ b/uppsrc/Core/src.tpp/Buffer$en-us.tpp @@ -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; ]] \ No newline at end of file