/** * @module cprogram * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) * @brief class for parsing and saving the program instuctions. * @date 17.04.2009 */ #ifndef CPROGRAM_H #define CPROGRAM_H #include #include #include #include #ifdef DEBUG # include #endif #include "cdat.h" /** * @class CProgram * * Parses a simple line based scriptfile with some limitations: * first function (starting a block) must be a read-command, * last must be a write-command (ending this block). * * read- and write-commands have hard coded parameters, number#1 being a filetype. * Classes handling certain filetypes must be of type CFile. * Custom functions will be passed to CFile::callFunc(). * * On error ParserError will be thrown. */ class CProgram { public: /** * @method CProgram * @brief Default ctor * @param programfile filename * @return - * @globalvars none * @exception bad_alloc * @conditions none */ CProgram(const std::string& progfile); /** * @method ~CScriptparser * @brief Default dtor * @param - * @return - * @globalvars none * @exception none * @conditions none */ ~CProgram(); CDat getMaxProgramCount() { return CDat(m_progsource.size()); } std::vector& getInstruction(CDat linenr) { return m_progsource[linenr.getTypeValue()]; } std::map& getJumpAddrs() { return m_jumpaddr; } #ifdef DEBUG /** * @method dump * @brief Dumps the program source to ostream * @param out output stream * @return - * @globalvars * @exception * @conditions */ void dump(std::ostream& out); #endif protected: /** * @method parse * @brief parse the program file * @param - * @return - * @globalvars none * @exception ParserError * @conditions none */ void parse(); private: /* members */ std::string m_programfile; std::vector > m_progsource; std::map m_jumpaddr; }; #endif /* vim: set et sw=2 ts=2: */