/* Aloe * Copyright (c) 2005 Michael Cohen, Robert C., and Zachary Howe * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU GPL license. See LICENSE for more details * * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef FILE_H #define FILE_H #include "aloeobj.h" #include class File : public AloeObj { public: AloeObj* reference(); void dereference(); Context* protcon(); std::string className(); double asNum(); std::string asString(); bool asBool(); bool equals(AloeObj* oobj); AloeObj* getvar(std::string varname); void setvar(std::string varname, AloeObj* obj); AloeObj* callfunc(std::string funcname, std::vector args); static File* create(std::string name, std::string mode); protected: class FileContext : public Context { AloeObj* getvar(std::string varname); void setvar(std::string varname, AloeObj* obj); AloeObj* callfunc(std::string funcname, std::vector args); }; File(std::string name, std::string mode); ~File(); int refcount; std::string mode; std::string name; std::fstream file; FileContext context; }; #endif