| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,26 +0,0 @@ |
| 1 |
-//taken from fceux on 27-oct-2008 |
|
| 2 |
-//subsequently modified for desmume |
|
| 3 |
- |
|
| 4 |
-/* |
|
| 5 |
- Copyright (C) 2008-2009 DeSmuME team |
|
| 6 |
- |
|
| 7 |
- This file is free software: you can redistribute it and/or modify |
|
| 8 |
- it under the terms of the GNU General Public License as published by |
|
| 9 |
- the Free Software Foundation, either version 2 of the License, or |
|
| 10 |
- (at your option) any later version. |
|
| 11 |
- |
|
| 12 |
- This file is distributed in the hope that it will be useful, |
|
| 13 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 |
- GNU General Public License for more details. |
|
| 16 |
- |
|
| 17 |
- You should have received a copy of the GNU General Public License |
|
| 18 |
- along with the this software. If not, see <http://www.gnu.org/licenses/>. |
|
| 19 |
-*/ |
|
| 20 |
- |
|
| 21 |
-#pragma once |
|
| 22 |
- |
|
| 23 |
-#include <string> |
|
| 24 |
-#include <vector> |
|
| 25 |
- |
|
| 26 |
-std::vector<std::string> tokenize_str(const std::string &str, const std::string &delims); |
| ... | ... |
@@ -18,12 +18,9 @@ |
| 18 | 18 |
along with the this software. If not, see <http://www.gnu.org/licenses/>. |
| 19 | 19 |
*/ |
| 20 | 20 |
|
| 21 |
-#ifndef _STRINGUTIL_H_ |
|
| 22 |
-#define _STRINGUTIL_H_ |
|
| 21 |
+#pragma once |
|
| 23 | 22 |
|
| 24 | 23 |
#include <string> |
| 25 | 24 |
#include <vector> |
| 26 | 25 |
|
| 27 | 26 |
std::vector<std::string> tokenize_str(const std::string &str, const std::string &delims); |
| 28 |
- |
|
| 29 |
-#endif |
| ... | ... |
@@ -23,112 +23,7 @@ |
| 23 | 23 |
|
| 24 | 24 |
#include <string> |
| 25 | 25 |
#include <vector> |
| 26 |
-//#include <iostream> |
|
| 27 |
-//#include <cstdio> |
|
| 28 |
-//#include <cstring> |
|
| 29 |
-//#include <cstdlib> |
|
| 30 | 26 |
|
| 31 |
-//#include "../types.h" |
|
| 32 |
-//#include "emufile.h" |
|
| 33 |
- |
|
| 34 |
-//definitions for str_strip() flags |
|
| 35 |
-//static const int STRIP_SP = 0x01; // space |
|
| 36 |
-//static const int STRIP_TAB = 0x02; // tab |
|
| 37 |
-//static const int STRIP_CR = 0x04; // carriage return |
|
| 38 |
-//static const int STRIP_LF = 0x08; // line feed |
|
| 39 |
- |
|
| 40 |
-//int str_ucase(char *str); |
|
| 41 |
-//int str_lcase(char *str); |
|
| 42 |
-//int str_ltrim(char *str, int flags); |
|
| 43 |
-//int str_rtrim(char *str, int flags); |
|
| 44 |
-//int str_strip(char *str, int flags); |
|
| 45 |
-//int chr_replace(char *str, char search, char replace); |
|
| 46 |
-//int str_replace(char *str, char *search, char *replace); |
|
| 47 |
- |
|
| 48 |
-//std::string strsub(const std::string &str, int pos, int len); |
|
| 49 |
-//std::string strmid(const std::string &str, int pos, int len); |
|
| 50 |
-//std::string strleft(const std::string &str, int len); |
|
| 51 |
-//std::string strright(const std::string &str, int len); |
|
| 52 |
-//std::string toupper(const std::string &str); |
|
| 53 |
- |
|
| 54 |
-//int HexStringToBytesLength(const std::string &str); |
|
| 55 |
-//int Base64StringToBytesLength(const std::string &str); |
|
| 56 |
-//std::string u32ToHexString(uint32_t val); |
|
| 57 |
-//std::string BytesToString(const void *data, int len); |
|
| 58 |
-//bool StringToBytes(const std::string &str, void *data, int len); |
|
| 59 |
- |
|
| 60 |
-std::vector<std::string> tokenize_str(const std::string &str,const std::string &delims); |
|
| 61 |
-//void splitpath(const char *path, char *drv, char *dir, char *name, char *ext); |
|
| 62 |
- |
|
| 63 |
-//uint16_t FastStrToU16(char *s, bool &valid); |
|
| 64 |
-//char *U16ToDecStr(uint16_t a); |
|
| 65 |
-//char *U32ToDecStr(uint32_t a); |
|
| 66 |
-//char *U32ToDecStr(char *buf, uint32_t a); |
|
| 67 |
-//char *U8ToDecStr(uint8_t a); |
|
| 68 |
-//char *U8ToHexStr(uint8_t a); |
|
| 69 |
-//char *U16ToHexStr(uint16_t a); |
|
| 70 |
- |
|
| 71 |
-//std::string stditoa(int n); |
|
| 72 |
- |
|
| 73 |
-//std::string readNullTerminatedAscii(std::istream *is); |
|
| 74 |
- |
|
| 75 |
-// extracts a decimal uint from an istream |
|
| 76 |
-/*template<typename T> T templateIntegerDecFromIstream(EMUFILE *is) |
|
| 77 |
-{
|
|
| 78 |
- unsigned int ret = 0; |
|
| 79 |
- bool pre = true; |
|
| 80 |
- |
|
| 81 |
- for (;;) |
|
| 82 |
- {
|
|
| 83 |
- int c = is->fgetc(); |
|
| 84 |
- if (c == -1) |
|
| 85 |
- return ret; |
|
| 86 |
- int d = c - '0'; |
|
| 87 |
- if (d < 0 || d > 9) |
|
| 88 |
- {
|
|
| 89 |
- if (!pre) |
|
| 90 |
- break; |
|
| 91 |
- } |
|
| 92 |
- else |
|
| 93 |
- {
|
|
| 94 |
- pre = false; |
|
| 95 |
- ret *= 10; |
|
| 96 |
- ret += d; |
|
| 97 |
- } |
|
| 98 |
- } |
|
| 99 |
- is->unget(); |
|
| 100 |
- return ret; |
|
| 101 |
-}*/ |
|
| 102 |
- |
|
| 103 |
-//inline uint32_t u32DecFromIstream(EMUFILE *is) { return templateIntegerDecFromIstream<uint32_t>(is); }
|
|
| 104 |
-//inline uint64_t u64DecFromIstream(EMUFILE *is) { return templateIntegerDecFromIstream<uint64_t>(is); }
|
|
| 105 |
- |
|
| 106 |
-//puts an optionally 0-padded decimal integer of type T into the ostream (0-padding is quicker) |
|
| 107 |
-/*template<typename T, int DIGITS, bool PAD> void putdec(EMUFILE *os, T dec) |
|
| 108 |
-{
|
|
| 109 |
- char temp[DIGITS]; |
|
| 110 |
- int ctr = 0; |
|
| 111 |
- for(int i = 0; i < DIGITS; ++i) |
|
| 112 |
- {
|
|
| 113 |
- int quot = dec / 10; |
|
| 114 |
- int rem = dec % 10; |
|
| 115 |
- temp[DIGITS - 1 - i] = '0' + rem; |
|
| 116 |
- if (!PAD && rem) |
|
| 117 |
- ctr = i; |
|
| 118 |
- dec = quot; |
|
| 119 |
- } |
|
| 120 |
- if (!PAD) |
|
| 121 |
- os->fwrite(temp + DIGITS - ctr - 1, ctr + 1); |
|
| 122 |
- else |
|
| 123 |
- os->fwrite(temp, DIGITS); |
|
| 124 |
-}*/ |
|
| 125 |
- |
|
| 126 |
-//std::string mass_replace(const std::string &source, const std::string &victim, const std::string &replacement); |
|
| 127 |
- |
|
| 128 |
-//std::wstring mbstowcs(std::string str); |
|
| 129 |
-//std::string wcstombs(std::wstring str); |
|
| 130 |
- |
|
| 131 |
-// TODO - dont we already have another function that can do this |
|
| 132 |
-//std::string getExtension(const char *input); |
|
| 27 |
+std::vector<std::string> tokenize_str(const std::string &str, const std::string &delims); |
|
| 133 | 28 |
|
| 134 | 29 |
#endif |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,134 @@ |
| 1 |
+//taken from fceux on 27-oct-2008 |
|
| 2 |
+//subsequently modified for desmume |
|
| 3 |
+ |
|
| 4 |
+/* |
|
| 5 |
+ Copyright (C) 2008-2009 DeSmuME team |
|
| 6 |
+ |
|
| 7 |
+ This file is free software: you can redistribute it and/or modify |
|
| 8 |
+ it under the terms of the GNU General Public License as published by |
|
| 9 |
+ the Free Software Foundation, either version 2 of the License, or |
|
| 10 |
+ (at your option) any later version. |
|
| 11 |
+ |
|
| 12 |
+ This file is distributed in the hope that it will be useful, |
|
| 13 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 |
+ GNU General Public License for more details. |
|
| 16 |
+ |
|
| 17 |
+ You should have received a copy of the GNU General Public License |
|
| 18 |
+ along with the this software. If not, see <http://www.gnu.org/licenses/>. |
|
| 19 |
+*/ |
|
| 20 |
+ |
|
| 21 |
+#ifndef _STRINGUTIL_H_ |
|
| 22 |
+#define _STRINGUTIL_H_ |
|
| 23 |
+ |
|
| 24 |
+#include <string> |
|
| 25 |
+#include <vector> |
|
| 26 |
+//#include <iostream> |
|
| 27 |
+//#include <cstdio> |
|
| 28 |
+//#include <cstring> |
|
| 29 |
+//#include <cstdlib> |
|
| 30 |
+ |
|
| 31 |
+//#include "../types.h" |
|
| 32 |
+//#include "emufile.h" |
|
| 33 |
+ |
|
| 34 |
+//definitions for str_strip() flags |
|
| 35 |
+//static const int STRIP_SP = 0x01; // space |
|
| 36 |
+//static const int STRIP_TAB = 0x02; // tab |
|
| 37 |
+//static const int STRIP_CR = 0x04; // carriage return |
|
| 38 |
+//static const int STRIP_LF = 0x08; // line feed |
|
| 39 |
+ |
|
| 40 |
+//int str_ucase(char *str); |
|
| 41 |
+//int str_lcase(char *str); |
|
| 42 |
+//int str_ltrim(char *str, int flags); |
|
| 43 |
+//int str_rtrim(char *str, int flags); |
|
| 44 |
+//int str_strip(char *str, int flags); |
|
| 45 |
+//int chr_replace(char *str, char search, char replace); |
|
| 46 |
+//int str_replace(char *str, char *search, char *replace); |
|
| 47 |
+ |
|
| 48 |
+//std::string strsub(const std::string &str, int pos, int len); |
|
| 49 |
+//std::string strmid(const std::string &str, int pos, int len); |
|
| 50 |
+//std::string strleft(const std::string &str, int len); |
|
| 51 |
+//std::string strright(const std::string &str, int len); |
|
| 52 |
+//std::string toupper(const std::string &str); |
|
| 53 |
+ |
|
| 54 |
+//int HexStringToBytesLength(const std::string &str); |
|
| 55 |
+//int Base64StringToBytesLength(const std::string &str); |
|
| 56 |
+//std::string u32ToHexString(uint32_t val); |
|
| 57 |
+//std::string BytesToString(const void *data, int len); |
|
| 58 |
+//bool StringToBytes(const std::string &str, void *data, int len); |
|
| 59 |
+ |
|
| 60 |
+std::vector<std::string> tokenize_str(const std::string &str,const std::string &delims); |
|
| 61 |
+//void splitpath(const char *path, char *drv, char *dir, char *name, char *ext); |
|
| 62 |
+ |
|
| 63 |
+//uint16_t FastStrToU16(char *s, bool &valid); |
|
| 64 |
+//char *U16ToDecStr(uint16_t a); |
|
| 65 |
+//char *U32ToDecStr(uint32_t a); |
|
| 66 |
+//char *U32ToDecStr(char *buf, uint32_t a); |
|
| 67 |
+//char *U8ToDecStr(uint8_t a); |
|
| 68 |
+//char *U8ToHexStr(uint8_t a); |
|
| 69 |
+//char *U16ToHexStr(uint16_t a); |
|
| 70 |
+ |
|
| 71 |
+//std::string stditoa(int n); |
|
| 72 |
+ |
|
| 73 |
+//std::string readNullTerminatedAscii(std::istream *is); |
|
| 74 |
+ |
|
| 75 |
+// extracts a decimal uint from an istream |
|
| 76 |
+/*template<typename T> T templateIntegerDecFromIstream(EMUFILE *is) |
|
| 77 |
+{
|
|
| 78 |
+ unsigned int ret = 0; |
|
| 79 |
+ bool pre = true; |
|
| 80 |
+ |
|
| 81 |
+ for (;;) |
|
| 82 |
+ {
|
|
| 83 |
+ int c = is->fgetc(); |
|
| 84 |
+ if (c == -1) |
|
| 85 |
+ return ret; |
|
| 86 |
+ int d = c - '0'; |
|
| 87 |
+ if (d < 0 || d > 9) |
|
| 88 |
+ {
|
|
| 89 |
+ if (!pre) |
|
| 90 |
+ break; |
|
| 91 |
+ } |
|
| 92 |
+ else |
|
| 93 |
+ {
|
|
| 94 |
+ pre = false; |
|
| 95 |
+ ret *= 10; |
|
| 96 |
+ ret += d; |
|
| 97 |
+ } |
|
| 98 |
+ } |
|
| 99 |
+ is->unget(); |
|
| 100 |
+ return ret; |
|
| 101 |
+}*/ |
|
| 102 |
+ |
|
| 103 |
+//inline uint32_t u32DecFromIstream(EMUFILE *is) { return templateIntegerDecFromIstream<uint32_t>(is); }
|
|
| 104 |
+//inline uint64_t u64DecFromIstream(EMUFILE *is) { return templateIntegerDecFromIstream<uint64_t>(is); }
|
|
| 105 |
+ |
|
| 106 |
+//puts an optionally 0-padded decimal integer of type T into the ostream (0-padding is quicker) |
|
| 107 |
+/*template<typename T, int DIGITS, bool PAD> void putdec(EMUFILE *os, T dec) |
|
| 108 |
+{
|
|
| 109 |
+ char temp[DIGITS]; |
|
| 110 |
+ int ctr = 0; |
|
| 111 |
+ for(int i = 0; i < DIGITS; ++i) |
|
| 112 |
+ {
|
|
| 113 |
+ int quot = dec / 10; |
|
| 114 |
+ int rem = dec % 10; |
|
| 115 |
+ temp[DIGITS - 1 - i] = '0' + rem; |
|
| 116 |
+ if (!PAD && rem) |
|
| 117 |
+ ctr = i; |
|
| 118 |
+ dec = quot; |
|
| 119 |
+ } |
|
| 120 |
+ if (!PAD) |
|
| 121 |
+ os->fwrite(temp + DIGITS - ctr - 1, ctr + 1); |
|
| 122 |
+ else |
|
| 123 |
+ os->fwrite(temp, DIGITS); |
|
| 124 |
+}*/ |
|
| 125 |
+ |
|
| 126 |
+//std::string mass_replace(const std::string &source, const std::string &victim, const std::string &replacement); |
|
| 127 |
+ |
|
| 128 |
+//std::wstring mbstowcs(std::string str); |
|
| 129 |
+//std::string wcstombs(std::wstring str); |
|
| 130 |
+ |
|
| 131 |
+// TODO - dont we already have another function that can do this |
|
| 132 |
+//std::string getExtension(const char *input); |
|
| 133 |
+ |
|
| 134 |
+#endif |