summaryrefslogtreecommitdiffstats
path: root/Source/cmXMLParser.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmXMLParser.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/cmXMLParser.cxx')
-rw-r--r--Source/cmXMLParser.cxx94
1 files changed, 37 insertions, 57 deletions
diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx
index e2f7afa..5e06d36 100644
--- a/Source/cmXMLParser.cxx
+++ b/Source/cmXMLParser.cxx
@@ -26,31 +26,27 @@ cmXMLParser::cmXMLParser()
cmXMLParser::~cmXMLParser()
{
- if ( this->Parser )
- {
+ if (this->Parser) {
this->CleanupParser();
- }
+ }
}
int cmXMLParser::Parse(const char* string)
{
return (int)this->InitializeParser() &&
- this->ParseChunk(string, strlen(string)) &&
- this->CleanupParser();
+ this->ParseChunk(string, strlen(string)) && this->CleanupParser();
}
int cmXMLParser::ParseFile(const char* file)
{
- if ( !file )
- {
+ if (!file) {
return 0;
- }
+ }
cmsys::ifstream ifs(file);
- if ( !ifs )
- {
+ if (!ifs) {
return 0;
- }
+ }
std::ostringstream str;
str << ifs.rdbuf();
@@ -59,18 +55,16 @@ int cmXMLParser::ParseFile(const char* file)
int cmXMLParser::InitializeParser()
{
- if ( this->Parser )
- {
+ if (this->Parser) {
std::cerr << "Parser already initialized" << std::endl;
this->ParseError = 1;
return 0;
- }
+ }
// Create the expat XML parser.
this->Parser = XML_ParserCreate(0);
XML_SetElementHandler(static_cast<XML_Parser>(this->Parser),
- &cmXMLParserStartElement,
- &cmXMLParserEndElement);
+ &cmXMLParserStartElement, &cmXMLParserEndElement);
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser),
&cmXMLParserCharacterDataHandler);
XML_SetUserData(static_cast<XML_Parser>(this->Parser), this);
@@ -81,39 +75,34 @@ int cmXMLParser::InitializeParser()
int cmXMLParser::ParseChunk(const char* inputString,
std::string::size_type length)
{
- if ( !this->Parser )
- {
+ if (!this->Parser) {
std::cerr << "Parser not initialized" << std::endl;
this->ParseError = 1;
return 0;
- }
+ }
int res;
res = this->ParseBuffer(inputString, length);
- if ( res == 0 )
- {
+ if (res == 0) {
this->ParseError = 1;
- }
+ }
return res;
}
int cmXMLParser::CleanupParser()
{
- if ( !this->Parser )
- {
+ if (!this->Parser) {
std::cerr << "Parser not initialized" << std::endl;
this->ParseError = 1;
return 0;
- }
+ }
int result = !this->ParseError;
- if(result)
- {
+ if (result) {
// Tell the expat XML parser about the end-of-input.
- if(!XML_Parse(static_cast<XML_Parser>(this->Parser), "", 0, 1))
- {
+ if (!XML_Parse(static_cast<XML_Parser>(this->Parser), "", 0, 1)) {
this->ReportXmlParseError();
result = 0;
- }
}
+ }
// Clean up the parser.
XML_ParserFree(static_cast<XML_Parser>(this->Parser));
@@ -125,12 +114,11 @@ int cmXMLParser::CleanupParser()
int cmXMLParser::ParseBuffer(const char* buffer, std::string::size_type count)
{
// Pass the buffer to the expat XML parser.
- if(!XML_Parse(static_cast<XML_Parser>(this->Parser), buffer,
- static_cast<int>(count), 0))
- {
+ if (!XML_Parse(static_cast<XML_Parser>(this->Parser), buffer,
+ static_cast<int>(count), 0)) {
this->ReportXmlParseError();
return 0;
- }
+ }
return 1;
}
@@ -145,8 +133,7 @@ int cmXMLParser::ParsingComplete()
return 0;
}
-void cmXMLParser::StartElement(const std::string& name,
- const char ** /*atts*/)
+void cmXMLParser::StartElement(const std::string& name, const char** /*atts*/)
{
std::cout << "Start element: " << name << std::endl;
}
@@ -157,7 +144,7 @@ void cmXMLParser::EndElement(const std::string& name)
}
void cmXMLParser::CharacterDataHandler(const char* /*inData*/,
- int /*inLength*/)
+ int /*inLength*/)
{
}
@@ -169,21 +156,17 @@ int cmXMLParser::IsSpace(char c)
const char* cmXMLParser::FindAttribute(const char** atts,
const char* attribute)
{
- if(atts && attribute)
- {
- for(const char** a = atts; *a && *(a+1); a += 2)
- {
- if(strcmp(*a, attribute) == 0)
- {
- return *(a+1);
- }
+ if (atts && attribute) {
+ for (const char** a = atts; *a && *(a + 1); a += 2) {
+ if (strcmp(*a, attribute) == 0) {
+ return *(a + 1);
}
}
+ }
return 0;
}
-void cmXMLParserStartElement(void* parser, const char *name,
- const char **atts)
+void cmXMLParserStartElement(void* parser, const char* name, const char** atts)
{
// Begin element handler that is registered with the XML_Parser.
// This just casts the user data to a cmXMLParser and calls
@@ -191,7 +174,7 @@ void cmXMLParserStartElement(void* parser, const char *name,
static_cast<cmXMLParser*>(parser)->StartElement(name, atts);
}
-void cmXMLParserEndElement(void* parser, const char *name)
+void cmXMLParserEndElement(void* parser, const char* name)
{
// End element handler that is registered with the XML_Parser. This
// just casts the user data to a cmXMLParser and calls EndElement.
@@ -199,7 +182,7 @@ void cmXMLParserEndElement(void* parser, const char *name)
}
void cmXMLParserCharacterDataHandler(void* parser, const char* data,
- int length)
+ int length)
{
// Character data handler that is registered with the XML_Parser.
// This just casts the user data to a cmXMLParser and calls
@@ -217,13 +200,10 @@ void cmXMLParser::ReportXmlParseError()
void cmXMLParser::ReportError(int line, int, const char* msg)
{
- if(this->ReportCallback)
- {
+ if (this->ReportCallback) {
this->ReportCallback(line, msg, this->ReportCallbackData);
- }
- else
- {
- std::cerr << "Error parsing XML in stream at line "
- << line << ": " << msg << std::endl;
- }
+ } else {
+ std::cerr << "Error parsing XML in stream at line " << line << ": " << msg
+ << std::endl;
+ }
}