1 /***************************************************************************
2                         stringzeug.h  -  description
3                              -------------------
4     begin                : Mon Mar 20 2006
5     copyright            : (C) 2006 by Mark Weyer
6     email                : cuyo-devel@nongnu.org
7 
8 Modified 2006,2008,2010,2011 by the cuyo developers
9 
10  ***************************************************************************/
11 
12 /***************************************************************************
13  *                                                                         *
14  *   This program is free software; you can redistribute it and/or modify  *
15  *   it under the terms of the GNU General Public License as published by  *
16  *   the Free Software Foundation; either version 2 of the License, or     *
17  *   (at your option) any later version.                                   *
18  *                                                                         *
19  ***************************************************************************/
20 
21 #ifndef STRINGZEUG_H
22 #define STRINGZEUG_H
23 
24 #include <config.h>
25 #include <cstdarg>
26 #include <string>
27 
28 
29 
30 
31 struct Str {
32   friend Str operator + (const Str &, const Str &);
33   friend Str operator + (const Str &, const char *);
34   friend Str operator + (const Str &, char);
35   friend Str operator + (char, const Str &);
36 
37 private:
38 
39   std::string inhalt;
40 
41   Str(const std::string &);
42 
43 public:
44 
45   Str();
46   Str(const char *);
47   Str(const Str &);
48 
49   bool isEmpty() const;
50   int length() const;
51   char operator [] (int) const;
52   char & operator [] (int);
53   const char * data() const;
54 
55   Str left(int) const;
56   Str mid(int, int) const;
57   Str right(int) const;
58 
59   void operator += (char);
60   void operator += (const Str &);
61 
62   bool operator == (const Str &) const;
63   bool operator < (const Str &) const;
64   bool operator != (const Str &) const;
65   bool operator != (const char *) const;
66 
67 };
68 
69 
70 Str operator + (const Str &, const Str &);
71 Str operator + (const Str &, const char *);
72 Str operator + (const Str &, char);
73 Str operator + (char, const Str &);
74 
75 Str _sprintf(const char * format, ...)
76 #ifdef __GNUC__
77   __attribute__ ((format (printf, 1, 2)))
78 #endif
79   ;
80 
81 Str _vsprintf(const char * format, va_list ap);
82 
83 void print_to_stderr(const Str &);
84 
85 #endif
86 
87