Bump for 3.6-28
[LibreOffice.git] / xml2cmp / source / support / sistr.hxx
bloba7f747ead0173415435be2a42e90b5cf5191010f
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 XML2CMP_SISTR_HXX
30 #define XML2CMP_SISTR_HXX
33 class Simstr
35 // INTERFACE
36 public:
37 // Constructors, destructor, '=' and typecasts
38 Simstr(
39 const char * str = 0);
40 Simstr( // Creates Simstr out of a copy of the described bytes within 'anyBytes'.
41 // Adds a '\0' at the end.
42 const char * anybytes,
43 int firstBytesPos,
44 int nrOfBytes);
45 virtual ~Simstr();
46 Simstr(
47 const Simstr & S);
48 Simstr & operator=(
49 const Simstr & S);
50 operator const char*() const;
52 // diverse utility functions
53 const char * str() const { return sz; }
54 char * s(); // CAUTION!!! // Only use when a function needs a 'char*' but
55 // still will NOT MODIFY THE STRING!
56 // Typecasts to 'const char*' are performed automatically.
57 int l() const; // Length of string without '\0' at end.
58 Simstr operator+(
59 const Simstr & S) const;
60 Simstr & operator+=(
61 const Simstr & S);
63 // comparison operators
64 bool operator==(
65 const Simstr & S) const;
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;
78 // 'List of characters' - functions
79 // insert - functions
80 void push_front(
81 char c);
82 void push_back(
83 char c);
84 void push_front(
85 const Simstr & S);
86 void push_back(
87 const Simstr & S);
88 // remove - functions
89 void remove(
90 int pos,
91 int anzahl = 1);
92 void remove_trailing_blanks();
94 // search functions
95 int pos_first(
96 char c) const;
97 int pos_last(
98 char c) const;
99 bool is_empty() const; // Only true if object == "".
100 bool is_no_text() const; // String may contain spaces or tabs.
102 // substitution functions
103 void replace_all(
104 char oldCh,
105 char newCh);
106 // token functions
107 // get...-functions return the token, separated by char 'c' and leave the object unchanged.
108 // take...-functions return the same, but remove the token and the corresponding separator from the object.
109 Simstr get_last_token(
110 char c) const;
112 private:
113 char * sz;
114 int len;
117 // Simstr - char* / char - concatenations
118 Simstr operator+(const char * str, const Simstr & S);
119 Simstr operator+(const Simstr & S, const char * str);
120 Simstr operator+(char c, const Simstr & S);
121 Simstr operator+(const Simstr & S, char c);
123 // Simstr - char* - comparison operators
124 bool operator==(const Simstr & S, const char * str);
125 bool operator!=(const Simstr & S, const char * str);
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 char * str, const Simstr & S);
131 bool operator!=(const char * str, const Simstr & S);
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);
138 inline char *
139 Simstr::s() { return sz; }
140 inline int
141 Simstr::l() const { return len; }
142 inline
143 Simstr::operator const char*() const { return sz; }
144 inline bool
145 Simstr::is_empty() const { return len == 0; }
148 #endif
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */