-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStrings.h
34 lines (27 loc) · 1.11 KB
/
Strings.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
//Strings.h
#ifndef NEO_TOOLBOX_STRINGS_H
#define NEO_TOOLBOX_STRINGS_H
#include <string>
#include <sstream>
namespace sdlUtility {
/// Functions used to manipulate strings.
namespace Strings {
int FindNthOf(int &Occurrence, char Character, const std::string &String);
int FindTotalOf(char Character, const std::string &String);
std::string Separate(const std::string &String, char Separator ='\0', int SubstringNumber = 0);
/// Converts a string to the specified type.
/** @param String The string to be converted.
@param Separator Optional delimiter character.
@param SubstringNumber Optional index of the requested value within a character-delimited string. */
template <class Type>
Type StringTo(const std::string &String, char Separator = '\0', int SubstringNumber = 0) {
Type Return;
std::string Substring;
Substring = Separate(String, Separator, SubstringNumber);
std::istringstream Stream(Substring);
Stream >> Return;
return Return;
}
}
}
#endif