Merge topic 'wix-cmake-coding-conventions'

37a1157 CPackWiX: adhere to CMake member naming convention
This commit is contained in:
Brad King 2013-12-23 10:19:29 -05:00 committed by CMake Topic Stage
commit b5ef7fd47e
8 changed files with 108 additions and 108 deletions

View File

@ -85,8 +85,8 @@ bool cmCPackWIXGenerator::RunCandleCommand(
command << " -arch " << GetArchitecture(); command << " -arch " << GetArchitecture();
command << " -out " << QuotePath(objectFile); command << " -out " << QuotePath(objectFile);
for(extension_set_t::const_iterator i = candleExtensions.begin(); for(extension_set_t::const_iterator i = CandleExtensions.begin();
i != candleExtensions.end(); ++i) i != CandleExtensions.end(); ++i)
{ {
command << " -ext " << QuotePath(*i); command << " -ext " << QuotePath(*i);
} }
@ -111,8 +111,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
command << " -nologo"; command << " -nologo";
command << " -out " << QuotePath(packageFileNames.at(0)); command << " -out " << QuotePath(packageFileNames.at(0));
for(extension_set_t::const_iterator i = lightExtensions.begin(); for(extension_set_t::const_iterator i = LightExtensions.begin();
i != lightExtensions.end(); ++i) i != LightExtensions.end(); ++i)
{ {
command << " -ext " << QuotePath(*i); command << " -ext " << QuotePath(*i);
} }
@ -211,12 +211,12 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
} }
CollectExtensions("CPACK_WIX_EXTENSIONS", candleExtensions); CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions);
CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", candleExtensions); CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions);
lightExtensions.insert("WixUIExtension"); LightExtensions.insert("WixUIExtension");
CollectExtensions("CPACK_WIX_EXTENSIONS", lightExtensions); CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions);
CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", lightExtensions); CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions);
const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
if(patchFilePath) if(patchFilePath)
@ -247,9 +247,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
AppendUserSuppliedExtraSources(); AppendUserSuppliedExtraSources();
std::stringstream objectFiles; std::stringstream objectFiles;
for(size_t i = 0; i < wixSources.size(); ++i) for(size_t i = 0; i < WixSources.size(); ++i)
{ {
const std::string& sourceFilename = wixSources[i]; const std::string& sourceFilename = WixSources[i];
std::string objectFilename = std::string objectFilename =
cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj"; cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj";
@ -272,7 +272,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES"); const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
if(!cpackWixExtraSources) return; if(!cpackWixExtraSources) return;
cmSystemTools::ExpandListArgument(cpackWixExtraSources, wixSources); cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources);
} }
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
@ -351,7 +351,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string directoryDefinitionsFilename = std::string directoryDefinitionsFilename =
cpackTopLevel + "/directories.wxs"; cpackTopLevel + "/directories.wxs";
wixSources.push_back(directoryDefinitionsFilename); WixSources.push_back(directoryDefinitionsFilename);
cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename); cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename);
directoryDefinitions.BeginElement("Fragment"); directoryDefinitions.BeginElement("Fragment");
@ -406,7 +406,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string fileDefinitionsFilename = std::string fileDefinitionsFilename =
cpackTopLevel + "/files.wxs"; cpackTopLevel + "/files.wxs";
wixSources.push_back(fileDefinitionsFilename); WixSources.push_back(fileDefinitionsFilename);
cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename); cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename);
fileDefinitions.BeginElement("Fragment"); fileDefinitions.BeginElement("Fragment");
@ -414,7 +414,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string featureDefinitionsFilename = std::string featureDefinitionsFilename =
cpackTopLevel +"/features.wxs"; cpackTopLevel +"/features.wxs";
wixSources.push_back(featureDefinitionsFilename); WixSources.push_back(featureDefinitionsFilename);
cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename); cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename);
featureDefinitions.BeginElement("Fragment"); featureDefinitions.BeginElement("Fragment");
@ -533,11 +533,11 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false; return false;
} }
wixSources.push_back(mainSourceFilePath); WixSources.push_back(mainSourceFilePath);
std::string fragmentList; std::string fragmentList;
for(cmWIXPatchParser::fragment_map_t::const_iterator for(cmWIXPatchParser::fragment_map_t::const_iterator
i = fragments.begin(); i != fragments.end(); ++i) i = Fragments.begin(); i != Fragments.end(); ++i)
{ {
if(!fragmentList.empty()) if(!fragmentList.empty())
{ {
@ -1018,8 +1018,8 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
std::string cmCPackWIXGenerator::PathToId(const std::string& path) std::string cmCPackWIXGenerator::PathToId(const std::string& path)
{ {
id_map_t::const_iterator i = pathToIdMap.find(path); id_map_t::const_iterator i = PathToIdMap.find(path);
if(i != pathToIdMap.end()) return i->second; if(i != PathToIdMap.end()) return i->second;
std::string id = CreateNewIdForPath(path); std::string id = CreateNewIdForPath(path);
return id; return id;
@ -1056,7 +1056,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
std::stringstream result; std::stringstream result;
result << idPrefix << "_" << identifier; result << idPrefix << "_" << identifier;
size_t ambiguityCount = ++idAmbiguityCounter[identifier]; size_t ambiguityCount = ++IdAmbiguityCounter[identifier];
if(ambiguityCount > 999) if(ambiguityCount > 999)
{ {
@ -1073,7 +1073,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
std::string resultString = result.str(); std::string resultString = result.str();
pathToIdMap[path] = resultString; PathToIdMap[path] = resultString;
return resultString; return resultString;
} }
@ -1181,15 +1181,15 @@ void cmCPackWIXGenerator::CreateStartMenuFolder(
void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath)
{ {
cmWIXPatchParser parser(fragments, Logger); cmWIXPatchParser parser(Fragments, Logger);
parser.ParseFile(patchFilePath.c_str()); parser.ParseFile(patchFilePath.c_str());
} }
void cmCPackWIXGenerator::ApplyPatchFragment( void cmCPackWIXGenerator::ApplyPatchFragment(
const std::string& id, cmWIXSourceWriter& writer) const std::string& id, cmWIXSourceWriter& writer)
{ {
cmWIXPatchParser::fragment_map_t::iterator i = fragments.find(id); cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
if(i == fragments.end()) return; if(i == Fragments.end()) return;
const cmWIXPatchElement& fragment = i->second; const cmWIXPatchElement& fragment = i->second;
for(cmWIXPatchElement::child_list_t::const_iterator for(cmWIXPatchElement::child_list_t::const_iterator
@ -1198,7 +1198,7 @@ void cmCPackWIXGenerator::ApplyPatchFragment(
ApplyPatchElement(**j, writer); ApplyPatchElement(**j, writer);
} }
fragments.erase(i); Fragments.erase(i);
} }
void cmCPackWIXGenerator::ApplyPatchElement( void cmCPackWIXGenerator::ApplyPatchElement(

View File

@ -169,14 +169,14 @@ private:
void ApplyPatchElement(const cmWIXPatchElement& element, void ApplyPatchElement(const cmWIXPatchElement& element,
cmWIXSourceWriter& writer); cmWIXSourceWriter& writer);
std::vector<std::string> wixSources; std::vector<std::string> WixSources;
id_map_t pathToIdMap; id_map_t PathToIdMap;
ambiguity_map_t idAmbiguityCounter; ambiguity_map_t IdAmbiguityCounter;
extension_set_t candleExtensions; extension_set_t CandleExtensions;
extension_set_t lightExtensions; extension_set_t LightExtensions;
cmWIXPatchParser::fragment_map_t fragments; cmWIXPatchParser::fragment_map_t Fragments;
}; };
#endif #endif

View File

@ -27,9 +27,9 @@ cmWIXPatchElement::~cmWIXPatchElement()
cmWIXPatchParser::cmWIXPatchParser( cmWIXPatchParser::cmWIXPatchParser(
fragment_map_t& fragments, cmCPackLog* logger): fragment_map_t& fragments, cmCPackLog* logger):
Logger(logger), Logger(logger),
state(BEGIN_DOCUMENT), State(BEGIN_DOCUMENT),
valid(true), Valid(true),
fragments(fragments) Fragments(fragments)
{ {
} }
@ -37,22 +37,22 @@ cmWIXPatchParser::cmWIXPatchParser(
void cmWIXPatchParser::StartElement(const char *name, const char **atts) void cmWIXPatchParser::StartElement(const char *name, const char **atts)
{ {
std::string name_str = name; std::string name_str = name;
if(state == BEGIN_DOCUMENT) if(State == BEGIN_DOCUMENT)
{ {
if(name_str == "CPackWiXPatch") if(name_str == "CPackWiXPatch")
{ {
state = BEGIN_FRAGMENTS; State = BEGIN_FRAGMENTS;
} }
else else
{ {
ReportValidationError("Expected root element 'CPackWiXPatch'"); ReportValidationError("Expected root element 'CPackWiXPatch'");
} }
} }
else if(state == BEGIN_FRAGMENTS) else if(State == BEGIN_FRAGMENTS)
{ {
if(name_str == "CPackWiXFragment") if(name_str == "CPackWiXFragment")
{ {
state = INSIDE_FRAGMENT; State = INSIDE_FRAGMENT;
StartFragment(atts); StartFragment(atts);
} }
else else
@ -60,9 +60,9 @@ void cmWIXPatchParser::StartElement(const char *name, const char **atts)
ReportValidationError("Expected 'CPackWixFragment' element"); ReportValidationError("Expected 'CPackWixFragment' element");
} }
} }
else if(state == INSIDE_FRAGMENT) else if(State == INSIDE_FRAGMENT)
{ {
cmWIXPatchElement &parent = *elementStack.back(); cmWIXPatchElement &parent = *ElementStack.back();
parent.children.resize(parent.children.size() + 1); parent.children.resize(parent.children.size() + 1);
cmWIXPatchElement*& currentElement = parent.children.back(); cmWIXPatchElement*& currentElement = parent.children.back();
@ -77,7 +77,7 @@ void cmWIXPatchParser::StartElement(const char *name, const char **atts)
currentElement->attributes[key] = value; currentElement->attributes[key] = value;
} }
elementStack.push_back(currentElement); ElementStack.push_back(currentElement);
} }
} }
@ -90,14 +90,14 @@ void cmWIXPatchParser::StartFragment(const char **attributes)
if(key == "Id") if(key == "Id")
{ {
if(fragments.find(value) != fragments.end()) if(Fragments.find(value) != Fragments.end())
{ {
std::stringstream tmp; std::stringstream tmp;
tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
ReportValidationError(tmp.str()); ReportValidationError(tmp.str());
} }
elementStack.push_back(&fragments[value]); ElementStack.push_back(&Fragments[value]);
} }
else else
{ {
@ -110,16 +110,16 @@ void cmWIXPatchParser::StartFragment(const char **attributes)
void cmWIXPatchParser::EndElement(const char *name) void cmWIXPatchParser::EndElement(const char *name)
{ {
std::string name_str = name; std::string name_str = name;
if(state == INSIDE_FRAGMENT) if(State == INSIDE_FRAGMENT)
{ {
if(name_str == "CPackWiXFragment") if(name_str == "CPackWiXFragment")
{ {
state = BEGIN_FRAGMENTS; State = BEGIN_FRAGMENTS;
elementStack.clear(); ElementStack.clear();
} }
else else
{ {
elementStack.pop_back(); ElementStack.pop_back();
} }
} }
} }
@ -129,7 +129,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while processing XML patch file at " << line << ":" << column << "Error while processing XML patch file at " << line << ":" << column <<
": "<< msg << std::endl); ": "<< msg << std::endl);
valid = false; Valid = false;
} }
void cmWIXPatchParser::ReportValidationError(const std::string& message) void cmWIXPatchParser::ReportValidationError(const std::string& message)
@ -141,5 +141,5 @@ void cmWIXPatchParser::ReportValidationError(const std::string& message)
bool cmWIXPatchParser::IsValid() const bool cmWIXPatchParser::IsValid() const
{ {
return valid; return Valid;
} }

View File

@ -40,7 +40,7 @@ class cmWIXPatchParser : public cmXMLParser
public: public:
typedef std::map<std::string, cmWIXPatchElement> fragment_map_t; typedef std::map<std::string, cmWIXPatchElement> fragment_map_t;
cmWIXPatchParser(fragment_map_t& fragments, cmCPackLog* logger); cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
private: private:
virtual void StartElement(const char *name, const char **atts); virtual void StartElement(const char *name, const char **atts);
@ -63,13 +63,13 @@ private:
INSIDE_FRAGMENT INSIDE_FRAGMENT
}; };
ParserState state; ParserState State;
bool valid; bool Valid;
fragment_map_t& fragments; fragment_map_t& Fragments;
std::list<cmWIXPatchElement*> elementStack; std::list<cmWIXPatchElement*> ElementStack;
}; };
#endif #endif

View File

@ -16,7 +16,7 @@
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
const std::string& filename): const std::string& filename):
file(filename.c_str(), std::ios::binary) File(filename.c_str(), std::ios::binary)
{ {
StartGroup(); StartGroup();
WriteHeader(); WriteHeader();
@ -29,8 +29,8 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter()
/* I haven't seen this in the RTF spec but /* I haven't seen this in the RTF spec but
* wordpad terminates its RTF like this */ * wordpad terminates its RTF like this */
file << "\r\n"; File << "\r\n";
file.put(0); File.put(0);
} }
void cmWIXRichTextFormatWriter::AddText(const std::string& text) void cmWIXRichTextFormatWriter::AddText(const std::string& text)
@ -44,16 +44,16 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text)
switch(c) switch(c)
{ {
case '\\': case '\\':
file << "\\\\"; File << "\\\\";
break; break;
case '{': case '{':
file << "\\{"; File << "\\{";
break; break;
case '}': case '}':
file << "\\}"; File << "\\}";
break; break;
case '\n': case '\n':
file << "\\par\r\n"; File << "\\par\r\n";
break; break;
case '\r': case '\r':
continue; continue;
@ -61,11 +61,11 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text)
{ {
if(c <= 0x7F) if(c <= 0x7F)
{ {
file << c; File << c;
} }
else else
{ {
file << "[NON-ASCII-" << int(c) << "]"; File << "[NON-ASCII-" << int(c) << "]";
} }
} }
break; break;
@ -103,7 +103,7 @@ void cmWIXRichTextFormatWriter::WriteGenerator()
{ {
StartGroup(); StartGroup();
NewControlWord("generator"); NewControlWord("generator");
file << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");"; File << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");";
EndGroup(); EndGroup();
} }
@ -118,20 +118,20 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword) void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword)
{ {
file << "\\" << keyword; File << "\\" << keyword;
} }
void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword) void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword)
{ {
file << "\\*\\" << keyword; File << "\\*\\" << keyword;
} }
void cmWIXRichTextFormatWriter::StartGroup() void cmWIXRichTextFormatWriter::StartGroup()
{ {
file.put('{'); File.put('{');
} }
void cmWIXRichTextFormatWriter::EndGroup() void cmWIXRichTextFormatWriter::EndGroup()
{ {
file.put('}'); File.put('}');
} }

View File

@ -40,7 +40,7 @@ private:
void StartGroup(); void StartGroup();
void EndGroup(); void EndGroup();
std::ofstream file; std::ofstream File;
}; };
#endif #endif

View File

@ -20,9 +20,9 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
const std::string& filename, const std::string& filename,
bool isIncludeFile): bool isIncludeFile):
Logger(logger), Logger(logger),
file(filename.c_str()), File(filename.c_str()),
state(DEFAULT), State(DEFAULT),
sourceFilename(filename) SourceFilename(filename)
{ {
WriteXMLDeclaration(); WriteXMLDeclaration();
@ -40,79 +40,79 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
cmWIXSourceWriter::~cmWIXSourceWriter() cmWIXSourceWriter::~cmWIXSourceWriter()
{ {
if(elements.size() > 1) if(Elements.size() > 1)
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
elements.size() - 1 << " WiX elements were still open when closing '" << Elements.size() - 1 << " WiX elements were still open when closing '" <<
sourceFilename << "'" << std::endl); SourceFilename << "'" << std::endl);
return; return;
} }
EndElement(elements.back()); EndElement(Elements.back());
} }
void cmWIXSourceWriter::BeginElement(const std::string& name) void cmWIXSourceWriter::BeginElement(const std::string& name)
{ {
if(state == BEGIN) if(State == BEGIN)
{ {
file << ">"; File << ">";
} }
file << "\n"; File << "\n";
Indent(elements.size()); Indent(Elements.size());
file << "<" << name; File << "<" << name;
elements.push_back(name); Elements.push_back(name);
state = BEGIN; State = BEGIN;
} }
void cmWIXSourceWriter::EndElement(std::string const& name) void cmWIXSourceWriter::EndElement(std::string const& name)
{ {
if(elements.empty()) if(Elements.empty())
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"can not end WiX element with no open elements in '" << "can not end WiX element with no open elements in '" <<
sourceFilename << "'" << std::endl); SourceFilename << "'" << std::endl);
return; return;
} }
if(elements.back() != name) if(Elements.back() != name)
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"WiX element <" << elements.back() << "WiX element <" << Elements.back() <<
"> can not be closed by </" << name << "> in '" << "> can not be closed by </" << name << "> in '" <<
sourceFilename << "'" << std::endl); SourceFilename << "'" << std::endl);
return; return;
} }
if(state == DEFAULT) if(State == DEFAULT)
{ {
file << "\n"; File << "\n";
Indent(elements.size()-1); Indent(Elements.size()-1);
file << "</" << elements.back() << ">"; File << "</" << Elements.back() << ">";
} }
else else
{ {
file << "/>"; File << "/>";
} }
elements.pop_back(); Elements.pop_back();
state = DEFAULT; State = DEFAULT;
} }
void cmWIXSourceWriter::AddProcessingInstruction( void cmWIXSourceWriter::AddProcessingInstruction(
const std::string& target, const std::string& content) const std::string& target, const std::string& content)
{ {
if(state == BEGIN) if(State == BEGIN)
{ {
file << ">"; File << ">";
} }
file << "\n"; File << "\n";
Indent(elements.size()); Indent(Elements.size());
file << "<?" << target << " " << content << "?>"; File << "<?" << target << " " << content << "?>";
state = DEFAULT; State = DEFAULT;
} }
void cmWIXSourceWriter::AddAttribute( void cmWIXSourceWriter::AddAttribute(
@ -120,7 +120,7 @@ void cmWIXSourceWriter::AddAttribute(
{ {
std::string utf8 = WindowsCodepageToUtf8(value); std::string utf8 = WindowsCodepageToUtf8(value);
file << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"';
} }
void cmWIXSourceWriter::AddAttributeUnlessEmpty( void cmWIXSourceWriter::AddAttributeUnlessEmpty(
@ -172,14 +172,14 @@ std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value)
void cmWIXSourceWriter::WriteXMLDeclaration() void cmWIXSourceWriter::WriteXMLDeclaration()
{ {
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
} }
void cmWIXSourceWriter::Indent(size_t count) void cmWIXSourceWriter::Indent(size_t count)
{ {
for(size_t i = 0; i < count; ++i) for(size_t i = 0; i < count; ++i)
{ {
file << " "; File << " ";
} }
} }

View File

@ -60,13 +60,13 @@ private:
cmCPackLog* Logger; cmCPackLog* Logger;
std::ofstream file; std::ofstream File;
State state; State State;
std::vector<std::string> elements; std::vector<std::string> Elements;
std::string sourceFilename; std::string SourceFilename;
}; };
#endif #endif