Changeset 382 for cpp/common
- Timestamp:
- 05/22/15 04:15:14 (10 years ago)
- Location:
- cpp/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/stl-util.cpp
r375 r382 12 12 #include <assert.h> 13 13 #ifdef USE_VIRTFILE 14 #include < frams/virtfile/virtfile.h>14 #include <common/virtfile/virtfile.h> 15 15 #endif 16 16 #ifdef __BORLANDC__ -
cpp/common/virtfile/stringfile.cpp
r348 r382 9 9 size_t StringFILE::Vread(void *ptr, size_t size, size_t nmemb) 10 10 { 11 int have = (int)(str.len() - pos);11 int have = int(str.size()) - pos; 12 12 if (have <= 0) return 0; 13 13 int need = (int)(size*nmemb); … … 20 20 int StringFILE::Vgetc() 21 21 { 22 if (pos >= str.len()) //...i znowu byl bug roku! :O22 if (pos >= int(str.size())) 23 23 return EOF; 24 24 else … … 28 28 char *StringFILE::Vgets(char *s, int size) 29 29 { 30 int have = str.len() - (int)pos;30 int have = int(str.size()) - pos; 31 31 if (have <= 0) return 0; 32 32 if (size < 0) size = 0; … … 49 49 case SEEK_SET: pos = offset; break; 50 50 case SEEK_CUR: pos += offset; break; 51 case SEEK_END: pos = str.len() - offset; break;51 case SEEK_END: pos = int(str.size()) - offset; break; 52 52 default: return EINVAL; 53 53 } 54 if (pos < 0) pos = 0; else if (pos >str.len()) pos = str.len();54 if (pos < 0) pos = 0; else if (pos > int(str.size())) pos = int(str.size()); 55 55 return 0; 56 56 } … … 67 67 if ((*mode == 'r') && isStringPath(path)) 68 68 { 69 return new StringFILE2( SString(path + sizeof(PREFIX) - 1));69 return new StringFILE2(string(path + sizeof(PREFIX) - 1)); 70 70 } 71 71 return (chain != NULL) ? chain->Vfopen(path, mode) : NULL; -
cpp/common/virtfile/stringfile.h
r295 r382 7 7 8 8 #include "virtfile.h" 9 #include <frams/util/sstring.h> 9 #include <common/nonstd_stl.h> 10 #include <string.h> 10 11 11 12 class StringFILE : public VirtFILE 12 13 { 13 14 protected: 14 SString& str;15 longpos;15 string& str; 16 int pos; 16 17 public: 17 StringFILE( SString& s): VirtFILE(""), str(s), pos(0) {}18 StringFILE(string& s): VirtFILE(""), str(s), pos(0) {} 18 19 size_t Vread(void *ptr, size_t size, size_t nmemb); 19 20 size_t Vwrite(const void *ptr, size_t size, size_t nmemb) { str.append((const char*)ptr, (int)(size*nmemb)); return size*nmemb; } 20 int Veof() { return pos >= str.len(); }21 int Veof() { return pos >= int(str.size()); } 21 22 int Vputc(int c) { str += (char)c; return c; } 22 23 int Vputs(const char *s) { str.append(s, (int)strlen(s)); return 0; } … … 31 32 class StringFILE2 : public StringFILE 32 33 { 33 SString string;34 string str; 34 35 public: 35 StringFILE2(const SString& s) :StringFILE(string), string(s) {}36 StringFILE2() :StringFILE(str ing) {}37 const SString& getString() { return string; }36 StringFILE2(const string& s) :StringFILE(str), str(s) {} 37 StringFILE2() :StringFILE(str) {} 38 const string& getString() { return str; } 38 39 }; 39 40
Note: See TracChangeset
for help on using the changeset viewer.