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