forked from augcampos/asterisk-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringUtils.h
More file actions
46 lines (35 loc) · 946 Bytes
/
StringUtils.h
File metadata and controls
46 lines (35 loc) · 946 Bytes
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
/*
* StringUtils.h
*
* Created on: Jul 7, 2011
* Author: augcampos
*/
#ifndef STRINGUTILS_H_
#define STRINGUTILS_H_
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
#ifdef WIN32
#include "timesupport.h"
#endif
namespace asteriskcpp {
template<class T>
static std::string convertToString(const T& t) {
std::ostringstream stream;
stream << t;
return (stream.str());
}
template<class T>
static T convertFromString(const std::string& s) {
std::istringstream stream(s);
T t;
stream >> t;
return (t);
}
std::string search_and_replace(const std::string& str, const std::string &oldsubstr, const std::string &newsubstr);
time_t stringToTime(const std::string& str, const std::string& format);
bool stringToBool(const std::string& str);
std::string str2Log(const std::string& str);
}
#endif /* STRINGUTILS_H_ */