/[H9]/trunk/tntnet/dynamic/common.h
ViewVC logotype

Contents of /trunk/tntnet/dynamic/common.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (show annotations) (download)
Tue Nov 27 17:08:11 2007 UTC (16 years, 5 months ago) by torben
File MIME type: text/plain
File size: 724 byte(s)
Getting closer towards a working solution :)

1 #ifndef _COMMON_H_
2 #define _COMMON_H_
3
4 #include <string>
5
6 inline std::string nl2br(const std::string& input)
7 {
8 std::string output = input;
9
10 std::string::size_type pos;
11 while( (pos=output.find( '\n')) != std::string::npos)
12 {
13 output.replace(pos,1, "<br>");
14 }
15
16 return output;
17 }
18
19 inline std::string ltrim(const std::string& input)
20 {
21 std::string output = input;
22 while ( ! isgraph(output[0]))
23 output.erase(0,1);
24 return output;
25 }
26
27 inline std::string rtrim(const std::string& input)
28 {
29 std::string output = input;
30 while (! isgraph(output[output.size()-1]))
31 output.erase(output.size()-1,1);
32 return output;
33 }
34
35 inline std::string trim(const std::string& input)
36 {
37 return ltrim(rtrim(input));
38 }
39
40
41 #endif // _COMMON_H_

  ViewVC Help
Powered by ViewVC 1.1.20