-
Notifications
You must be signed in to change notification settings - Fork 0
/
stringtools.h
107 lines (78 loc) · 2.98 KB
/
stringtools.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/***************************************************************************
stringtools.h - description
-------------------
begin : Mon Dec 10 2001
copyright : (C) 2001 by André Simon
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef STRINGTOOLS_H
#define STRINGTOOLS_H
#include <string>
#include <cctype>
#include <vector>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <cmath>
#include <cstdlib>
#include <sys/param.h>
#include <unistd.h>
#define WS_CHARS " \n\r\t"
#ifdef _WIN32
#define PATH_SEPARATOR_CHAR '\\'
#define PATH_SEPARATOR_STR "\\"
#else
#define PATH_SEPARATOR_CHAR '/'
#define PATH_SEPARATOR_STR "/"
#endif
using namespace std;
/**Methoden zur Stringbearbeitung
*@author Andre Simon
*/
namespace StringTools
{
/**get current working directory**/
string getcwd_str();
string genfilename(const string& pref, const string &suff,
int nfields, int nxyz);
/** \param s String
\returns lowercase string */
string lowerCase(const string &s);
double atod(const string &s);
/** \param String
\returns Integer value */
int str2int(string &s);
/** gibt integer als String zurueck */
string int2str(int integer, int size=0, const string spaceStr= " ");
string double2str(double val, int precision);
string double2str1(double val);
/** gibt True zurueck, falls c ein Buchstabe ist */
bool isAlpha(unsigned char c);
/** wandelt String s in Integer um */
int str2int(unsigned char *s);
/* entfernt whitespace von stringende*/
string trimRight(const string &);
/** gibt naechsten Character der Zeile zurck, der kein Whitespace ist*/
unsigned char getNextNonWs(const string &line, int index=0);
unsigned int getNextNonWsPos(const string &line, int index=0);
string validateDirPath(const string & path);
int cleanstring(string& line);
string newCleanString(string line);
vector<string> tokenize(string str, string delims);
bool findstr(ifstream &fstr, string tag);
bool findstr(ifstream &fstr, string tag, string & outstring);
bool contains(string s1, string s2);
bool iscomment(string s);
void quickSort(vector<int>& A, int p, int q);
int partition(vector<int> & A, int p, int q);
};
#endif