* src/native/jni.cpp: [OPENJDK] Implemented jni_GetDirectBufferCapacity.
[cacao.git] / src / toolbox / sequence.hpp
1 /* src/toolbox/sequence.hpp - sequence builder class header
2
3    Copyright (C) 2009
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5    Copyright (C) 2009 Theobroma Systems Ltd.
6
7    This file is part of CACAO.
8
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License as
11    published by the Free Software Foundation; either version 2, or (at
12    your option) any later version.
13
14    This program is distributed in the hope that it will be useful, but
15    WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22    02110-1301, USA.
23
24 */
25
26
27 #ifndef _SEQUENCE_HPP
28 #define _SEQUENCE_HPP
29
30 #include "config.h"
31
32 #include <string>
33
34
35 /**
36  * This class is a mutable and dynamically growing character sequence.
37  * Its main purpose is to dynamically construct Strings or Symbols which
38  * both are immutable.
39  *
40  * The buffer backing up this class is automatically (re)allocated as the
41  * sequence grows, no additional length checks are required. Furthermore
42  * the buffer memory is released once the builder is destructed and it's
43  * content is destroyed. To preserve the content, it has to be exported
44  * with one of the exporting functions.
45  */
46 class SequenceBuilder {
47 private:
48         std::string _str;
49
50 public:
51         // Constructor.
52         SequenceBuilder() {}
53
54         // Concatenation operations.
55         void cat(char ch)        { _str.push_back(ch); }
56         void cat(char ch, int n) { _str.append(n, ch); }
57         void cat(const char* s)  { _str.append(s); }
58
59         // Exporting functions.
60         //Object* export_string();
61         //Symbol* export_symbol();
62
63         // Be careful and see std::string::c_str() for details.
64         const char* c_str() const { return _str.c_str(); }
65 };
66
67
68 #endif // _SEQUENCE_HPP
69
70
71 /*
72  * These are local overrides for various environment variables in Emacs.
73  * Please do not remove this and leave it at the end of the file, where
74  * Emacs will automagically detect them.
75  * ---------------------------------------------------------------------
76  * Local variables:
77  * mode: c++
78  * indent-tabs-mode: t
79  * c-basic-offset: 4
80  * tab-width: 4
81  * End:
82  * vim:noexpandtab:sw=4:ts=4:
83  */