Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 969 | runge | 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2003 by Mattias Runge * |
||
| 3 | * mattias@mrunge.se * |
||
| 4 | * * |
||
| 5 | * This program is free software; you can redistribute it and/or modify * |
||
| 6 | * it under the terms of the GNU General Public License as published by * |
||
| 7 | * the Free Software Foundation; either version 2 of the License, or * |
||
| 8 | * (at your option) any later version. * |
||
| 9 | * * |
||
| 10 | * This program is distributed in the hope that it will be useful, * |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
| 13 | * GNU General Public License for more details. * |
||
| 14 | * * |
||
| 15 | * You should have received a copy of the GNU General Public License * |
||
| 16 | * along with this program; if not, write to the * |
||
| 17 | * Free Software Foundation, Inc., * |
||
| 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
| 19 | ***************************************************************************/ |
||
| 20 | #ifndef _TOOLS_H |
||
| 21 | #define _TOOLS_H |
||
| 22 | |||
| 23 | #include <string> |
||
| 24 | #include <vector> |
||
| 25 | #include <fstream> |
||
| 26 | #include <sstream> |
||
| 997 | runge | 27 | #include <stdexcept> |
| 28 | #include <iostream> |
||
| 969 | runge | 29 | |
| 30 | using namespace std; |
||
| 31 | |||
| 32 | #include <cmath> |
||
| 33 | #include <sys/types.h> |
||
| 34 | #include <dirent.h> |
||
| 35 | |||
| 981 | runge | 36 | string niceTime(); |
| 37 | |||
| 969 | runge | 38 | string hex2bin(string hex); |
| 39 | string bin2hex(string bin); |
||
| 40 | |||
| 41 | float bin2float(string bin); |
||
| 42 | string float2bin(float num, int length); |
||
| 43 | |||
| 44 | unsigned int bin2uint(string bin); |
||
| 45 | string uint2bin(unsigned int num, int length); |
||
| 46 | |||
| 981 | runge | 47 | string uint2hex(unsigned int num, int length); |
| 48 | |||
| 969 | runge | 49 | vector<string> explode(string delimiter, string str); |
| 50 | string strtoupper(string s); |
||
| 51 | string strtolower(string s); |
||
| 52 | string trim(string s); |
||
| 53 | string trim(string s, char c); |
||
| 54 | int stoi(const string s); |
||
| 55 | string itos(int i); |
||
| 981 | runge | 56 | string utos(unsigned int i); |
| 57 | unsigned int stou(const string s); |
||
| 969 | runge | 58 | float stof(const string s); |
| 59 | string ftos(float f); |
||
| 60 | string str_replace(string search, string replace, string str); |
||
| 61 | string file_get_contents(string filename); |
||
| 62 | bool file_exists(string filename); |
||
| 63 | string escape(string in); |
||
| 976 | runge | 64 | string rpad(string in, int length, char c); |
| 65 | string lpad(string in, int length, char c); |
||
| 969 | runge | 66 | |
| 67 | class FileTools |
||
| 68 | { |
||
| 69 | public: |
||
| 70 | static vector<string> GetDirList(string path); |
||
| 71 | static string GetUniqeFilename(string path, string prefix, string postfix); |
||
| 72 | static string GetUniqeFilename(string path) { return GetUniqeFilename(path, "", ""); } |
||
| 73 | static bool SaveFile(string filepath, string data); |
||
| 74 | static string Get(string src); |
||
| 75 | static bool Copy(string src, string dest); |
||
| 76 | static bool Exist(string filename); |
||
| 77 | |||
| 78 | }; |
||
| 79 | |||
| 80 | #endif // _TOOLS_H |