source: cpp/frams/virtfile/stringfile.h @ 196

Last change on this file since 196 was 121, checked in by sz, 11 years ago

updated file headers and makefiles

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#ifndef _STRINGFILE_H_
6#define _STRINGFILE_H_
7
8#include "virtfile.h"
9#include <frams/util/sstring.h>
10
11class StringFILE: public VirtFILE
12{
13  protected:
14SString& str;
15long pos;
16  public:
17StringFILE(SString& s):str(s),pos(0) {}
18int Vread(void *ptr, size_t size, size_t nmemb);
19int Vwrite(const void *ptr, size_t size, size_t nmemb) {str.append((const char*)ptr,size*nmemb); return size*nmemb;}
20int Veof() {return pos>=str.len();}
21int Vputc(int c) {str+=(char)c; return c;}
22int Vputs(const char *s) {str.append(s,strlen(s)); return 0;}
23int Vgetc();
24char *Vgets(char *s, int size);
25int Vprintf(const char *format, va_list args);
26int Vseek(long offset, int whence);
27int Vtell() {return pos;}
28void Vrewind() {pos=0;}
29int Vflush() {return 0;}
30};
31
32/** this version owns the string object */
33class StringFILE2: public StringFILE
34{
35SString string;
36  public:
37StringFILE2(const SString& s):StringFILE(string),string(s) {}
38StringFILE2():StringFILE(string) {}
39const SString& getString() {return string;}
40};
41
42class StringFileSystem: public VirtFileSystem
43{
44  public:
45VirtFileSystem *chain;
46StringFileSystem(VirtFileSystem *_chain):chain(_chain) {}
47VirtFILE *Vfopen(const char* path,const char*mode);
48int Vfexists(const char* path);
49VirtDIR *Vopendir(const char* path);
50static const char PREFIX[];
51static bool isStringPath(const char* path);
52};
53
54#endif
Note: See TracBrowser for help on using the repository browser.