[Compbench-devel] CompBenchmarks++/libcompbenchmarks/Compiler Compiler-Option.cpp, NONE, 1.1 Compil
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-05-17 14:29:51
|
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8051 Added Files: Compiler-Option.cpp Compiler-Option.h Compiler-OptionSet.cpp Compiler-OptionSet.h Log Message: First import. --- NEW FILE: Compiler-Option.h --- /* ---------------------------------------------------------------------------- $Id: Compiler-Option.h,v 1.1 2007/05/17 14:29:47 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBMCOMPILER_OPTION #define H_CBMCOMPILER_OPTION #include <Base/XML.h> namespace CBM { /** \brief Abstraction layer for hanling compilers' option. * */ class CompilerOption { private: /** Stores options. Initialised by constructor. * \sa Options() */ std::string option; protected: public: /** Constructor \param _options Options to manage in current object. */ CompilerOption(std::string _option); CompilerOption(); /** Retrives option \return Option (to compiler instance) declared in constructor */ virtual std::string Option(void); virtual XMLNode *XML(void); virtual void restore(XMLNode *_from); virtual ~CompilerOption(); }; } #endif --- NEW FILE: Compiler-Option.cpp --- /* ---------------------------------------------------------------------------- $Id: Compiler-Option.cpp,v 1.1 2007/05/17 14:29:47 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <Compiler/Compiler-Option.h> using namespace CBM; CompilerOption::CompilerOption(std::string _option) { option=_option; } CompilerOption::CompilerOption() { option="unset"; } std::string CompilerOption::Option(void) { return(option); } XMLNode *CompilerOption::XML(void) { XMLNode *N = new XMLNode("option"); N->addAttribute("id", option); return(N); } void CompilerOption::restore(XMLNode *_from) { XMLAttribute *A = _from->getAttribute("id"); if (A) option=A->Value(); } CompilerOption::~CompilerOption() { } --- NEW FILE: Compiler-OptionSet.cpp --- /* ---------------------------------------------------------------------------- $Id: Compiler-OptionSet.cpp,v 1.1 2007/05/17 14:29:47 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <Compiler/Compiler-OptionSet.h> #include <Compiler/Compiler-Options.h> using namespace CBM; CompilerOptionSet::CompilerOptionSet(std::string _id) { id=_id; } std::string CompilerOptionSet::Id(void) { return(id); } void CompilerOptionSet::setId(std::string _id) { id=_id; } CBM::CompilerOptions *CompilerOptionSet::add(void) { CBM::CompilerOptions *result; result=new CBM::CompilerOptions(); options.push_back(result); return(result); } int CompilerOptionSet::remove(CBM::CompilerOptions *_options) { int i; int n = optionNumber(); CBM::CompilerOptions *O = 0; std::vector<CBM::CompilerOptions*> noptions; for(i=0; i<n; i++) { O=options[i]; if (O != _options) noptions.push_back(O); else delete(O); } options=noptions; return(1); } XMLNode *CompilerOptionSet::XML(void) { int i, n = optionNumber(); CompilerOptions *O; XMLNode *root = new XMLNode("option-set"); root->addAttribute("id", Id()); for(i=0; i<n; i++) { O=options[i]; root->add(O->XML()); } return(root); } void CompilerOptionSet::restore(CBM::XMLNode *_from) { int i; int n = _from->nodeNumber(); CBM::XMLNode *N; CBM::XMLAttribute *A; CompilerOptions *O; A=_from->getAttribute("id"); if (A) setId(A->Value()); else setId("unnamed"); for(i=0; i<n; i++) { N=_from->getNode(i); if (N->Name() != "options") continue; O=add(); O->restore(N); } } int CompilerOptionSet::optionNumber(void) { return(options.size()); } std::string CompilerOptionSet::Options(int i) { if (i<optionNumber()) return(options[i]->Options()); else return(""); } CompilerOptionSet::~CompilerOptionSet() { } --- NEW FILE: Compiler-OptionSet.h --- /* ---------------------------------------------------------------------------- $Id: Compiler-OptionSet.h,v 1.1 2007/05/17 14:29:47 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBMCOMPILER_OPTIONSET #define H_CBMCOMPILER_OPTIONSET #include <Base/XML.h> #ifdef SWIG /* !!! If in SWIG parser, we need to define CBM::CompilerOptions so that all methods get * correctly wrapped. Hope there's a better solution... */ %module CBM %{ #include <Compiler/Compiler-Options.h> %} #include <Compiler/Compiler-Options.h> #define CBM_CO CBM::CompilerOptions #else # define CBM_CO class CompilerOptions #endif namespace CBM { /** \brief Class for handling a set of compiler's options */ class CompilerOptionSet { private: std::vector<CBM_CO*> options; std::string id; protected: public: /** Constructor */ CompilerOptionSet(std::string _id); virtual std::string Id(void); virtual void setId(std::string _id); virtual CBM_CO *add(void); virtual int remove(CBM_CO *_options); virtual XMLNode *XML(void); virtual void restore(CBM::XMLNode *_from); virtual int optionNumber(void); virtual std::string Options(int i); virtual ~CompilerOptionSet(); }; } #endif |