tjstring.h
1 /***************************************************************************
2  tjstring.h - description
3  -------------------
4  begin : Mon Mar 10 2003
5  copyright : (C) 2000-2015 by Thies Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #ifndef TJSTRING_H
20 #define TJSTRING_H
21 
22 
23 #include <tjutils/tjutils.h>
24 //#include <tjutils/tjstream.h>
25 #include <tjutils/tjtools.h>
26 
32 #define _DEFAULT_DIGITS_ 5
33 #define _DEFAULT_LINEWIDTH_ 74
34 
35 #ifdef USING_WIN32
36 #define SEPARATOR_STR "\\"
37 #define SEPARATOR_CHAR '\\'
38 #else
39 #define SEPARATOR_STR "/"
40 #define SEPARATOR_CHAR '/'
41 #endif
42 
43 
45 
46 // class for debugging string component
47 class StringComp {
48  public:
49  static const char* get_compName();
50 };
51 
53 
54 
60 enum whichOccurences {allOccurences,firstOccurence};
61 
62 
64 // String helper functions
65 
66 
72  STD_string replaceStr(const STD_string& s, const STD_string& searchstring, const STD_string& replacement, whichOccurences mode=allOccurences);
73 
84  STD_string extract(const STD_string& s, const STD_string& blockbegin, const STD_string& blockend, bool hierachical=false, int beginpos=0);
85 
86 
96  STD_string rmblock(const STD_string& s, const STD_string& blockbegin, const STD_string& blockend,
97  bool rmbegin=true, bool rmend=true, bool rmall=true, bool hierachical=false);
98 
99 
104  STD_string toupperstr(const STD_string& s);
105 
106 
111  STD_string tolowerstr(const STD_string& s);
112 
119 enum expFormat {autoExp, alwaysExp, neverExp};
120 
121 
126  STD_string ftos (double f, unsigned int digits=_DEFAULT_DIGITS_, expFormat eformat=autoExp);
127 
128 
135  STD_string itos (int i, unsigned int maxabs=0);
136 
141  STD_string ptos (const void* p);
142 
147  STD_string n_times(const STD_string& s, unsigned int n);
148 
153  STD_string justificate(const STD_string& s, unsigned int indention=0,bool ignore_firstline=false, unsigned int linewidth=_DEFAULT_LINEWIDTH_);
154 
155 
162  int textbegin(const STD_string& s, int startpos=0, const char custom_separator=0);
163 
170  int sepbegin(const STD_string& s, int startpos=0, const char custom_separator=0);
171 
176  STD_string shrink(const STD_string& s);
177 
183  int noccur(const STD_string& s, const STD_string& searchstring);
184 
189  STD_string dos2unix(const STD_string& s);
190 
196  int load(STD_string& str, const STD_string& filename);
197 
204  int write(const STD_string& str, const STD_string& filename, fopenMode mode=overwriteMode);
205 
206 
207 
210 #endif
STD_string justificate(const STD_string &s, unsigned int indention=0, bool ignore_firstline=false, unsigned int linewidth=_DEFAULT_LINEWIDTH_)
STD_string rmblock(const STD_string &s, const STD_string &blockbegin, const STD_string &blockend, bool rmbegin=true, bool rmend=true, bool rmall=true, bool hierachical=false)
STD_string ptos(const void *p)
int noccur(const STD_string &s, const STD_string &searchstring)
STD_string n_times(const STD_string &s, unsigned int n)
STD_string replaceStr(const STD_string &s, const STD_string &searchstring, const STD_string &replacement, whichOccurences mode=allOccurences)
int textbegin(const STD_string &s, int startpos=0, const char custom_separator=0)
expFormat
Definition: tjstring.h:119
int write(const STD_string &str, const STD_string &filename, fopenMode mode=overwriteMode)
STD_string ftos(double f, unsigned int digits=_DEFAULT_DIGITS_, expFormat eformat=autoExp)
STD_string tolowerstr(const STD_string &s)
fopenMode
Definition: tjtools.h:107
int load(STD_string &str, const STD_string &filename)
whichOccurences
Definition: tjstring.h:60
STD_string shrink(const STD_string &s)
STD_string toupperstr(const STD_string &s)
STD_string extract(const STD_string &s, const STD_string &blockbegin, const STD_string &blockend, bool hierachical=false, int beginpos=0)
STD_string dos2unix(const STD_string &s)
STD_string itos(int i, unsigned int maxabs=0)
int sepbegin(const STD_string &s, int startpos=0, const char custom_separator=0)