ENH: Changed cmCableWrapCommand to inherit from cmCableDefineSetCommand since they do almost exactly the same thing. Added a GetXmlTag virtual function to both classes to return what XML tag to generate in the set's output. cmCableDefineSetCommand generates a "Set" tag, and cmCableWrapCommand generates a "WrapperSet" tag. What is inside the tags is still generated by the cmCableDefineSetCommand superclass.

This commit is contained in:
Brad King 2001-05-01 17:37:45 -04:00
parent 45e9d19c6c
commit 1d4a3aa48e
4 changed files with 19 additions and 46 deletions

View File

@ -103,7 +103,7 @@ void cmCableDefineSetCommand::WriteConfiguration() const
cmCableData::Indentation indent = m_CableData->GetIndentation();
// Output the code.
os << indent << "<Set name=\"" << m_SetName.c_str() << "\">" << std::endl;
os << indent << "<" << this->GetXmlTag() << " name=\"" << m_SetName.c_str() << "\">" << std::endl;
for(std::vector<std::string>::const_iterator e = m_SourceHeaders.begin();
e != m_SourceHeaders.end(); ++e)
{
@ -135,7 +135,7 @@ void cmCableDefineSetCommand::WriteConfiguration() const
}
os << "</Element>" << std::endl;
}
os << indent << "</Set>" << std::endl;
os << indent << "</" << this->GetXmlTag() << ">" << std::endl;
}

View File

@ -106,7 +106,8 @@ public:
cmTypeMacro(cmCableDefineSetCommand, cmCableCommand);
private:
protected:
virtual const char* GetXmlTag() const { return "Set"; }
void WriteConfiguration() const;
bool AddElement(const std::string&);
bool GenerateTag(const std::string&, std::string&);

View File

@ -41,38 +41,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "cmCableWrapCommand.h"
#include "cmCacheManager.h"
/**
* Write the CABLE configuration code to define this WrapperSet.
*/
bool cmCableWrapCommand::WriteConfiguration()
{
if(m_Entries.size() < 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
cmRegularExpression needCdataBlock("[&<>]");
Entries::const_iterator e = m_Entries.begin();
os << indent << "<WrapperSet name=\"" << e->c_str() << "\">" << std::endl;
for(++e;e != m_Entries.end(); ++e)
{
os << indent << " <Element>";
if(needCdataBlock.find(e->c_str()))
{
os << "<![CDATA[" << e->c_str() << "]]>";
}
else
{
os << e->c_str();
}
os << "</Element>" << std::endl;
}
os << indent << "</WrapperSet>" << std::endl;
return true;
}
// Don't need to implement anything here.

View File

@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define cmCableWrapCommand_h
#include "cmStandardIncludes.h"
#include "cmCablePackageEntryCommand.h"
#include "cmCableDefineSetCommand.h"
/** \class cmCableWrapCommand
* \brief Define a command that generates a rule for CABLE-generated wrappers.
@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* cmCableWrapCommand is used to generate a rule in a CABLE
* configuration file to create type wrappers.
*/
class cmCableWrapCommand : public cmCablePackageEntryCommand
class cmCableWrapCommand : public cmCableDefineSetCommand
{
public:
/**
@ -71,7 +71,7 @@ public:
*/
virtual const char* GetTerseDocumentation()
{
return "Define CABLE WrapSet in a package.";
return "Define CABLE WrapperSet in a package.";
}
/**
@ -80,13 +80,19 @@ public:
virtual const char* GetFullDocumentation()
{
return
"CABLE_WRAP(member1 member2 ...)\n"
"Generates a WrapSet in the CABLE configuration.";
"CABLE_WRAP(name_of_set [[tag1]:]memeber1 [[tag2]:]member2 ...\n"
" [SOURCE_FILES source1 source2 ...]] )\n"
"Generates a WrapperSet definition in the CABLE configuration.\n"
"If a the \"tag:\" syntax is not used, an attempt is made to\n"
"auto-generate a meaningful tag. If the SOURCE_FILES keyword is\n"
"given, all arguments after it refer to header files to be included\n"
"in the package in which the set is defined.\n";
}
virtual bool WriteConfiguration();
cmTypeMacro(cmCableWrapCommand, cmCablePackageCommand);
cmTypeMacro(cmCableWrapCommand, cmCableDefineSetCommand);
protected:
virtual const char* GetXmlTag() const { return "WrapperSet"; }
};