Changeset 941 for cpp/common


Ignore:
Timestamp:
06/05/20 17:11:29 (5 years ago)
Author:
Maciej Komosinski
Message:

Added the ability to create StringFILE2 object from const char*

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/virtfile/stringfile.h

    r887 r941  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1616        int pos;
    1717public:
    18         StringFILE(string& s,int _pos=0): VirtFILE(""), str(s), pos(_pos) {}
     18        StringFILE(string& s, int _pos = 0) : VirtFILE(""), str(s), pos(_pos) {}
    1919        size_t Vread(void *ptr, size_t size, size_t nmemb);
    20         size_t Vwrite(const void *ptr, size_t size, size_t nmemb) { str.append((const char*)ptr, (int)(size*nmemb)); return nmemb; }
     20        size_t Vwrite(const void *ptr, size_t size, size_t nmemb) { str.append((const char*)ptr, (int)(size * nmemb)); return nmemb; }
    2121        int Veof() { return pos >= int(str.size()); }
    2222        int Vputc(int c) { str += (char)c; return c; }
     
    3636        string str;
    3737public:
    38         StringFILE2(const string& s,int pos=0) :StringFILE(str,pos), str(s) {}
     38        StringFILE2(const string& s, int pos = 0) :StringFILE(str, pos), str(s) {}
     39        StringFILE2(const char* s, int pos = 0) :StringFILE(str, pos), str(s) {}
    3940        StringFILE2() :StringFILE(str) {}
    4041};
     
    4344{
    4445public:
    45         StringFileSystem(VirtFileSystem *_chain = NULL):ChainFileSystem(_chain) {}
     46        StringFileSystem(VirtFileSystem *_chain = NULL) :ChainFileSystem(_chain) {}
    4647        VirtFILE *Vfopen(const char* path, const char*mode);
    4748        static const char PREFIX[];
Note: See TracChangeset for help on using the changeset viewer.