Changeset 382 for cpp/common


Ignore:
Timestamp:
05/22/15 04:15:14 (10 years ago)
Author:
sz
Message:

Moving frams/virtfile to common/virtfile:

  • file references updated (includes, makefile)
  • common/virtfile can no longer use the Framsticks specific SString (using std::string instead)
Location:
cpp/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/stl-util.cpp

    r375 r382  
    1212#include <assert.h>
    1313#ifdef USE_VIRTFILE
    14 #include <frams/virtfile/virtfile.h>
     14#include <common/virtfile/virtfile.h>
    1515#endif
    1616#ifdef __BORLANDC__
  • cpp/common/virtfile/stringfile.cpp

    r348 r382  
    99size_t StringFILE::Vread(void *ptr, size_t size, size_t nmemb)
    1010{
    11         int have = (int)(str.len() - pos);
     11        int have = int(str.size()) - pos;
    1212        if (have <= 0) return 0;
    1313        int need = (int)(size*nmemb);
     
    2020int StringFILE::Vgetc()
    2121{
    22         if (pos >= str.len()) //...i znowu byl bug roku! :O
     22        if (pos >= int(str.size()))
    2323                return EOF;
    2424        else
     
    2828char *StringFILE::Vgets(char *s, int size)
    2929{
    30         int have = str.len() - (int)pos;
     30        int have = int(str.size()) - pos;
    3131        if (have <= 0) return 0;
    3232        if (size < 0) size = 0;
     
    4949        case SEEK_SET: pos = offset; break;
    5050        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;
    5252        default: return EINVAL;
    5353        }
    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());
    5555        return 0;
    5656}
     
    6767        if ((*mode == 'r') && isStringPath(path))
    6868        {
    69                 return new StringFILE2(SString(path + sizeof(PREFIX) - 1));
     69                return new StringFILE2(string(path + sizeof(PREFIX) - 1));
    7070        }
    7171        return (chain != NULL) ? chain->Vfopen(path, mode) : NULL;
  • cpp/common/virtfile/stringfile.h

    r295 r382  
    77
    88#include "virtfile.h"
    9 #include <frams/util/sstring.h>
     9#include <common/nonstd_stl.h>
     10#include <string.h>
    1011
    1112class StringFILE : public VirtFILE
    1213{
    1314protected:
    14         SString& str;
    15         long pos;
     15        string& str;
     16        int pos;
    1617public:
    17         StringFILE(SString& s): VirtFILE(""), str(s), pos(0) {}
     18        StringFILE(string& s): VirtFILE(""), str(s), pos(0) {}
    1819        size_t Vread(void *ptr, size_t size, size_t nmemb);
    1920        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()); }
    2122        int Vputc(int c) { str += (char)c; return c; }
    2223        int Vputs(const char *s) { str.append(s, (int)strlen(s)); return 0; }
     
    3132class StringFILE2 : public StringFILE
    3233{
    33         SString string;
     34        string str;
    3435public:
    35         StringFILE2(const SString& s) :StringFILE(string), string(s) {}
    36         StringFILE2() :StringFILE(string) {}
    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; }
    3839};
    3940
Note: See TracChangeset for help on using the changeset viewer.