nis-util
1.0.D108
|
00001 // 00002 // nis-util - NIS Administration Utilities 00003 // Copyright (C) 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License along 00016 // with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef LIB_RCSTRING_ACCUMULATOR_H 00020 #define LIB_RCSTRING_ACCUMULATOR_H 00021 00022 #include <lib/rcstring.h> 00023 00028 class rcstring_accumulator 00029 { 00030 public: 00035 ~rcstring_accumulator(); 00036 00040 rcstring_accumulator(); 00041 00048 rcstring_accumulator(const rcstring_accumulator &rhs); 00049 00056 rcstring_accumulator &operator=(const rcstring_accumulator &rhs); 00057 00065 void push_back(char c); 00066 00074 void push_back(unsigned char c); 00075 00083 void push_back(const char *text); 00084 00094 void push_back(const char *text, size_t text_size); 00095 00103 void push_back(const rcstring &text); 00104 00110 void pop_back(void); 00111 00116 unsigned char back(void) const; 00117 00125 void push_front(unsigned char c); 00126 00132 void pop_front(void); 00133 00145 void pop_front(size_t nbytes); 00146 00151 unsigned char front(void) const; 00152 00157 rcstring mkstr(void) const; 00158 00167 void clear(void) { data_size = 0; } 00168 00173 size_t size(void) const { return data_size; } 00174 00179 bool empty(void) const { return (data_size == 0); } 00180 00185 const char *get_data(void) const { return data; } 00186 00187 private: 00195 char *data; 00196 00204 size_t data_size; 00205 00212 size_t data_alloc; 00213 00224 void grow(size_t nbytes); 00225 }; 00226 00227 // vim: set ts=8 sw=4 et : 00228 #endif // LIB_RCSTRING_ACCUMULATOR_H