1 #ifndef _DEPOOLSTRING_HPP
2 #define _DEPOOLSTRING_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements C++ Base Library
5 * -----------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Memory pool -backed string.
24 *//*--------------------------------------------------------------------*/
27 #include "deMemPool.hpp"
28 #include "dePoolArray.hpp"
36 /*--------------------------------------------------------------------*//*!
37 * \brief String template backed by memory pool
39 * \note Memory in PoolString is not contiguous so pointer arithmetic
40 * to access next element(s) doesn't work.
41 *//*--------------------------------------------------------------------*/
42 class PoolString : public PoolArray<char>
45 explicit PoolString (MemPool* pool);
46 PoolString (MemPool* pool, const PoolString& other);
49 void toString (std::string& str) const;
50 std::string toString (void) const;
52 void append (const char* str);
53 void append (const std::string& str);
54 void append (const PoolString& str);
56 PoolString& operator= (const char* str) { clear(); append(str); return *this; }
57 PoolString& operator= (const std::string& str) { clear(); append(str); return *this; }
58 PoolString& operator= (const PoolString& str);
60 PoolString& operator+= (const char* str) { append(str); return *this; }
61 PoolString& operator+= (const std::string& str) { append(str); return *this; }
62 PoolString& operator+= (const PoolString& str) { append(str); return *this; }
65 PoolString (const PoolString& other);
69 std::ostream& operator<< (std::ostream& stream, const PoolString& string);
71 // PoolString inline implementations.
73 inline PoolString::PoolString (MemPool* pool)
74 : PoolArray<char>(pool)
78 inline PoolString::~PoolString (void)
82 inline std::string PoolString::toString (void) const
89 inline PoolString& PoolString::operator= (const PoolString& str)
101 #endif // _DEPOOLSTRING_HPP