~ubuntu-branches/ubuntu/natty/kdeadmin/natty-proposed

« back to all changes in this revision

Viewing changes to lilo-config/common/String.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-02-27 21:36:45 UTC
  • mfrom: (1.2.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20100227213645-ronst6mahkgf6j9w
Tags: 4:4.4.1-0ubuntu1
* New upstream release
  - Bump build-depends
  - Update kcron.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* String.h
2
 
**
3
 
** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer
4
 
**
5
 
** Contributions by A. Seigo and W. Bastian.
6
 
**
7
 
*/
8
 
 
9
 
/*
10
 
** This program is free software; you can redistribute it and/or modify
11
 
** it under the terms of the GNU General Public License as published by
12
 
** the Free Software Foundation; either version 2 of the License, or
13
 
** (at your option) any later version.
14
 
**
15
 
** This program is distributed in the hope that it will be useful,
16
 
** but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 
** GNU General Public License for more details.
19
 
**
20
 
** You should have received a copy of the GNU General Public License
21
 
** along with this program in a file called COPYING; if not, write to
22
 
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23
 
** MA 02110-1301, USA.
24
 
*/
25
 
 
26
 
/*
27
 
** Bug reports and questions can be sent to <kde-devel@kde.org>
28
 
*/
29
 
/* Somewhat more sane string handling functions...                        *
30
 
 * Should be portable, therefore we aren't simply using QString.          */
31
 
 
32
 
#ifndef _STRING_H_
33
 
#define _STRING_H_ 1
34
 
#include <string>
35
 
#include <list>
36
 
#include <iostream>
37
 
#include <stdarg.h>
38
 
 
39
 
class String;
40
 
class StringList;
41
 
 
42
 
typedef std::list<String> strlist;
43
 
 
44
 
class String:public std::string {
45
 
public:
46
 
        String():std::string("") { }
47
 
        String(char const * const &s):std::string(s) { }
48
 
        String(std::string const &s):std::string(s) { }
49
 
        String const operator +(char const &s);
50
 
        String const operator +(char const * const s);
51
 
        bool operator ==(char s);
52
 
        bool operator !=(char s);
53
 
        operator char * () const { return cstr(); }
54
 
        char * cstr() const;
55
 
        bool cmp(char const * const s) const;
56
 
        bool casecmp(char const * const s) const;
57
 
        bool contains(String const &s, bool cs=true) const;
58
 
        int locate(String const &s, bool cs=true, unsigned int startat=0) const;
59
 
        void sprintf(const char *format, ...);
60
 
        bool readfile(String filename);
61
 
        String simplifyWhiteSpace() const;
62
 
        String left(unsigned int num=1) const;
63
 
        String right(unsigned int num=1) const;
64
 
        String mid(unsigned int start, unsigned int num=0) const;
65
 
        String &regex(String const &expr, bool cs=true) const;
66
 
        String &replace(String const &what, String const &with, bool all=true) const;
67
 
        static String escapeForRegExp(String const &s);
68
 
        char chr(unsigned int index) const { if(index>=size()) return 0; else return data()[index]; }
69
 
        int length() const { return size(); } // For compatibility with QString
70
 
        char const *latin1() const { return cstr(); } // For compatibility with QString
71
 
};
72
 
 
73
 
class StringList:public strlist {
74
 
public:
75
 
        StringList() { clear(); }
76
 
        StringList(String const &s);
77
 
        StringList(char **strs, int num=-1);
78
 
        bool readfile(String const &filename);
79
 
        bool writefile(String const &filename) const;
80
 
        void operator +=(String const &s) { insert(end(), s); }
81
 
        void operator +=(char const * const &s) { insert(end(), s); }
82
 
        void operator +=(StringList const &s);
83
 
        void operator +=(StringList const * const s);
84
 
        operator String() const;
85
 
        bool contains(String const &s) const;
86
 
        void remove(String const &s);
87
 
        void add(String const &s) { insert(end(), s); }
88
 
        String const &grep(String const &s) const;
89
 
        void sort(bool cs=true);
90
 
};
91
 
 
92
 
std::ostream &operator <<(std::ostream &os, String const &s);
93
 
std::ostream &operator <<(std::ostream &os, String const *s);
94
 
std::ostream &operator <<(std::ostream &os, StringList const &s);
95
 
std::ostream &operator <<(std::ostream &os, StringList const *s);
96
 
#endif