1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef SOLTOOLS_SIMSTR_HXX
30 #define SOLTOOLS_SIMSTR_HXX
33 class Simstr
/// Simple string class.
39 const char * str
= 0);
40 Simstr( /** Creates Simstr out of a copy of the first
41 'nrOfBytes' bytes of 'anyBytes'.
42 Adds a '\0' at the end. */
43 const char * anybytes
,
45 Simstr( /** Creates Simstr out of a copy of the described bytes within 'anyBytes'.
46 Adds a '\0' at the end. */
47 const char * anybytes
,
50 Simstr( /// Creates Simstr of 'anzahl' times 'c'.
59 operator const char*() const;
65 const Simstr
& S
) const;
72 const Simstr
& S
) const;
74 const Simstr
& S
) const;
76 const Simstr
& S
) const;
78 const Simstr
& S
) const;
80 const Simstr
& S
) const;
82 const Simstr
& S
) const;
87 const char * str() const;
88 int l() const; // Length of string without '\0' at end.
89 char * s(); // ATTENTION !!! // Only to be used, when a function needs a 'char*' but
90 // nevertheless THAT WILL BE NOT CHANGED!
91 // Typecasts to 'const char*' are performed automatically.
94 char get_front() const;
95 char get_back() const;
108 int startSearchPos
) const;
112 const Simstr
& S
) const;
114 const Simstr
& S
) const;
117 bool is_empty() const; // Only true if object == "".
118 bool is_no_text() const; // String may contain spaces or tabs.
120 Simstr
get_first_token(
122 Simstr
get_last_token(
126 char & ch( /** Reference to sz[n]. Allows change of this char.
127 !!! No safety, if n is out of the allowed range! */
149 void remove_trailing_blanks();
155 int removeStartPos
);
158 void remove_all( // Starts search left.
161 char c
); // Removes all characters == c from front and back.
162 // c == ' ' removes also TABs !!!
163 void empty(); // Changes object to the value "".
177 const Simstr
& newS
);
180 Simstr
take_first_token( /// Token is removed from the Simstr.
182 Simstr
take_last_token( /// Token is removed from the Simstr.
190 // Simstr - char* / char - concatenations
191 Simstr
operator+(const char * str
, const Simstr
& S
);
192 Simstr
operator+(const Simstr
& S
, const char * str
);
193 Simstr
operator+(char c
, const Simstr
& S
);
194 Simstr
operator+(const Simstr
& S
, char c
);
196 // Simstr - char* - comparison operators
197 bool operator==(const Simstr
& S
, const char * str
);
198 bool operator!=(const Simstr
& S
, const char * str
);
199 bool operator<(const Simstr
& S
, const char * str
);
200 bool operator>(const Simstr
& S
, const char * str
);
201 bool operator<=(const Simstr
& S
, const char * str
);
202 bool operator>=(const Simstr
& S
, const char * str
);
203 bool operator==(const char * str
, const Simstr
& S
);
204 bool operator!=(const char * str
, const Simstr
& S
);
205 bool operator<(const char * str
, const Simstr
& S
);
206 bool operator>(const char * str
, const Simstr
& S
);
207 bool operator<=(const char * str
, const Simstr
& S
);
208 bool operator>=(const char * str
, const Simstr
& S
);
212 Simstr::str() const { return sz
; }
214 Simstr::s() { return sz
; }
216 Simstr::l() const { return len
; }
218 Simstr::operator const char*() const { return sz
; }
220 Simstr::is_empty() const { return len
== 0; }
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */