Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv4035
Added Files:
Compiler-Option-Description.cpp Compiler-Option-Description.h
Log Message:
First import.
--- NEW FILE: Compiler-Option-Description.cpp ---
/* ----------------------------------------------------------------------------
$Id: Compiler-Option-Description.cpp,v 1.1 2007/03/14 19:27:21 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-Description.h>
#include <CEL/CEL-Include.h>
#include <Base/XMLReader.h>
using namespace CBM;
CompilerOptionDescription::CompilerOptionDescription(CBM::XMLNode *_from)
{
int i;
int n = _from->nodeNumber();
CBM::XMLNode *N;
CBM::XMLAttribute *A;
A=_from->getAttribute("id");
if (A)
id=A->Value();
for(i=0; i<n; i++) {
N=_from->getNode(i);
if (N->Name() == "value")
option=N->Value();
if (N->Name() == "short-description")
shortDescription=N->Value();
if (N->Name() == "editor-description")
editorDescription=N->Value();
}
}
std::string CompilerOptionDescription::Id(void)
{
return(id);
}
std::string CompilerOptionDescription::ShortDescription(void)
{
return(shortDescription);
}
std::string CompilerOptionDescription::EditorDescription(void)
{
return(editorDescription);
}
std::string CompilerOptionDescription::Option(void)
{
return(option);
}
CompilerOptionDescription::~CompilerOptionDescription()
{
}
CompilerOptionDescriptions::CompilerOptionDescriptions(std::string _compilerId)
{
std::string fileName = _compilerId;
XMLNode *root;
XMLNode *N;
int i;
int n;
CompilerOptionDescription *D;
XMLReader R;
fileName+="/description.xml";
fileName=CBM::CelFullIncludeName(fileName);
root=R.read(fileName);
if (!root)
return;
if (root->Name() != "options")
return;
if (!root)
return;
n=root->nodeNumber();
for(i=0; i<n; i++) {
N=root->getNode(i);
D=new CompilerOptionDescription(N);
options.push_back(D);
}
}
int CompilerOptionDescriptions::DescriptionNumber(void)
{
return(options.size());
}
CompilerOptionDescription *CompilerOptionDescriptions::Description(int _index)
{
if (_index<DescriptionNumber())
return(options[_index]);
else
return(0);
}
CompilerOptionDescription *CompilerOptionDescriptions::Description(std::string _id)
{
CompilerOptionDescription *D;
int i;
int n = DescriptionNumber();
for(i=0; i<n; i++) {
D=options[i];
if (D->Id() == _id)
return(D);
}
return(0);
}
CompilerOptionDescriptions::~CompilerOptionDescriptions()
{
CompilerOptionDescription *D;
int i;
int n = DescriptionNumber();
for(i=0; i<n; i++) {
D=Description(i);
delete(D);
}
}
--- NEW FILE: Compiler-Option-Description.h ---
/* ----------------------------------------------------------------------------
$Id: Compiler-Option-Description.h,v 1.1 2007/03/14 19:27:21 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_DESCRIPTION
#define H_CBMCOMPILER_OPTION_DESCRIPTION
#include <Base/XML.h>
namespace CBM {
/** \brief Interface helping to describe compiler' option.
*/
class CompilerOptionDescription
{
private:
/** Stores options. Initialised by constructor.
* \sa Options()
*/
std::string id;
std::string shortDescription;
std::string editorDescription;
std::string option;
protected:
public:
/** Constructor
\param _from XML node to initialise object
*/
CompilerOptionDescription(XMLNode *_from);
/** Get option's internal ID
\return std::string with ID */
virtual std::string Id(void);
/** Get option's short description
\return std::string containing a short description */
virtual std::string ShortDescription(void);
/** Get editor's compiler option description
\return std::string containing the option's editor description */
virtual std::string EditorDescription(void);
/** Retrieves compiler's option
\return Option string to pass to compiler */
virtual std::string Option(void);
virtual ~CompilerOptionDescription();
};
class CompilerOptionDescriptions
{
private:
std::vector<CompilerOptionDescription*> options;
protected:
public:
CompilerOptionDescriptions(std::string _compilerId);
virtual int DescriptionNumber(void);
virtual CompilerOptionDescription *Description(int _index);
virtual CompilerOptionDescription *Description(std::string _id);
virtual ~CompilerOptionDescriptions();
};
}
#endif
|