Update ooo320-m1
[ooovba.git] / xml2cmp / source / support / sistr.hxx
blob796984058b0b660b10c9dc3a8c26968c540de415
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sistr.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef XML2CMP_SISTR_HXX
32 #define XML2CMP_SISTR_HXX
35 class Simstr
37 // INTERFACE
38 public:
39 // Constructors, destructor, '=' and typecasts
40 Simstr(
41 const char * str = 0);
42 Simstr( // Creates Simstr out of a copy of the described bytes within 'anyBytes'.
43 // Adds a '\0' at the end.
44 const char * anybytes,
45 int firstBytesPos,
46 int nrOfBytes);
47 virtual ~Simstr();
48 Simstr(
49 const Simstr & S);
50 Simstr & operator=(
51 const Simstr & S);
52 operator const char*() const;
54 // diverse utility functions
55 const char * str() const { return sz; }
56 char * s(); // ATTENTION !!! // Only to be used, when a function needs a 'char*' but
57 // nevertheless THAT WILL BE NOT CHANGED!
58 // Typecasts to 'const char*' are performed automatically.
59 int l() const; // Length of string without '\0' at end.
60 Simstr operator+(
61 const Simstr & S) const;
62 Simstr & operator+=(
63 const Simstr & S);
65 // comparison operators
66 bool operator==(
67 const Simstr & S) const;
68 bool operator!=(
69 const Simstr & S) const;
70 bool operator<(
71 const Simstr & S) const;
72 bool operator>(
73 const Simstr & S) const;
74 bool operator<=(
75 const Simstr & S) const;
76 bool operator>=(
77 const Simstr & S) const;
80 // 'List of characters' - functions
81 // insert - functions
82 void push_front(
83 char c);
84 void push_back(
85 char c);
86 void push_front(
87 const Simstr & S);
88 void push_back(
89 const Simstr & S);
90 // remove - functions
91 void remove(
92 int pos,
93 int anzahl = 1);
94 void remove_trailing_blanks();
96 // search functions
97 int pos_first(
98 char c) const;
99 int pos_last(
100 char c) const;
101 bool is_empty() const; // Only true if object == "".
102 bool is_no_text() const; // String may contain spaces or tabs.
104 // substitution functions
105 void replace_all(
106 char oldCh,
107 char newCh);
108 // token functions
109 // get...-functions return the token, separated by char 'c' and leave the object unchanged.
110 // take...-functions return the same, but remove the token and the corresponding separator from the object.
111 Simstr get_last_token(
112 char c) const;
114 private:
115 char * sz;
116 int len;
119 // Simstr - char* / char - concatenations
120 Simstr operator+(const char * str, const Simstr & S);
121 Simstr operator+(const Simstr & S, const char * str);
122 Simstr operator+(char c, const Simstr & S);
123 Simstr operator+(const Simstr & S, char c);
125 // Simstr - char* - comparison operators
126 bool operator==(const Simstr & S, const char * str);
127 bool operator!=(const Simstr & S, const char * str);
128 bool operator<(const Simstr & S, const char * str);
129 bool operator>(const Simstr & S, const char * str);
130 bool operator<=(const Simstr & S, const char * str);
131 bool operator>=(const Simstr & S, const char * str);
132 bool operator==(const char * str, const Simstr & S);
133 bool operator!=(const char * str, const Simstr & S);
134 bool operator<(const char * str, const Simstr & S);
135 bool operator>(const char * str, const Simstr & S);
136 bool operator<=(const char * str, const Simstr & S);
137 bool operator>=(const char * str, const Simstr & S);
140 inline char *
141 Simstr::s() { return sz; }
142 inline int
143 Simstr::l() const { return len; }
144 inline
145 Simstr::operator const char*() const { return sz; }
146 inline bool
147 Simstr::is_empty() const { return len == 0; }
150 #endif