// --------------------------------------------------------------------------- // - Cell.hpp - // - afnix:sps module - cell class definition - // --------------------------------------------------------------------------- // - This program is free software; you can redistribute it and/or modify - // - it provided that this copyright notice is kept intact. - // - - // - This program is distributed in the hope that it will be useful, but - // - without any warranty; without even the implied warranty of - // - merchantability or fitness for a particular purpose. In no event shall - // - the copyright holder be liable for any direct, indirect, incidental or - // - special damages arising in any way out of the use of this software. - // --------------------------------------------------------------------------- // - copyright (c) 1999-2007 amaury darsch - // --------------------------------------------------------------------------- #ifndef AFNIX_CELL_HPP #define AFNIX_CELL_HPP #ifndef AFNIX_STRING_HPP #include "String.hpp" #endif namespace afnix { /// The Cell class is the foundation block of the afnix spreadsheet module. /// A cell is a simple binding between a name and a literal object. For this /// reason a cell is a serializable object. The cell name does not have to /// exists for the cell to operate. /// @author amaury darsch class Cell : public Serial { private: /// the cell quark long d_quark; /// the cell object Literal* p_cobj; /// the const flag bool d_const; public: /// create an empty cell Cell (void); /// create a cell with a literal /// @param cobj the cell object Cell (Literal* cobj); /// create a cell with a name and an object /// @param name the cell name /// @param cobj the cell object Cell (const String& name, Literal* cobj); /// copy construct this cell /// @param that the cell to copy Cell (const Cell& that); /// destroy this cell ~Cell (void); /// @return the object name String repr (void) const; /// @ return a clone of this object Object* clone (void) const; /// assign a cell to this one /// @paarm that the cell to assign Cell& operator = (const Cell& that); /// check that the cell match the quark /// @param quark the quark to match bool operator == (const long quark) const; /// @return the cell serial id t_byte serialid (void) const; /// serialize this cell /// @param os the output stream void wrstream (Output& os) const; /// deserialize this cell /// @param is the input stream void rdstream (Input& os); /// @return the cell name String getname (void) const; /// set the cell name /// @param name the cell name to set void setname (const String& name); /// @return the cell value Literal* get (void) const; /// set the cell value void set (Literal* cobj); /// @return the cell string literal String tostring (void) const; public: /// create a new object in a generic way /// @param argv the argument vector static Object* mknew (Vector* argv); /// @return true if the given quark is defined bool isquark (const long quark, const bool hflg) const; /// set an object to this object /// @param robj the current runnable /// @param nset the current nameset /// @param object the object to set Object* vdef (Runnable* robj, Nameset* nset, Object* object); /// apply this object with a set of arguments and a quark /// @param robj the current runnable /// @param nset the current nameset /// @param quark the quark to apply these arguments /// @param argv the arguments to apply Object* apply (Runnable* robj, Nameset* nset, const long quark, Vector* argv); }; } #endif