Removed all trailing whitespace

- addresses #105
This commit is contained in:
Phil Nash
2013-07-03 19:14:59 +01:00
parent 503d5d0c8e
commit f3d1f08c3b
62 changed files with 527 additions and 527 deletions

View File

@@ -17,18 +17,18 @@ namespace Catch {
class XmlWriter {
public:
class ScopedElement {
public:
ScopedElement( XmlWriter* writer )
: m_writer( writer )
{}
ScopedElement( ScopedElement const& other )
: m_writer( other.m_writer ){
other.m_writer = NULL;
}
~ScopedElement() {
if( m_writer )
m_writer->endElement();
@@ -44,11 +44,11 @@ namespace Catch {
m_writer->writeAttribute( name, attribute );
return *this;
}
private:
mutable XmlWriter* m_writer;
};
XmlWriter()
: m_tagIsOpen( false ),
m_needsNewline( false ),
@@ -60,7 +60,7 @@ namespace Catch {
m_needsNewline( false ),
m_os( &os )
{}
~XmlWriter() {
while( !m_tags.empty() )
endElement();
@@ -71,7 +71,7 @@ namespace Catch {
swap( temp );
return *this;
}
void swap( XmlWriter& other ) {
std::swap( m_tagIsOpen, other.m_tagIsOpen );
std::swap( m_needsNewline, other.m_needsNewline );
@@ -79,7 +79,7 @@ namespace Catch {
std::swap( m_indent, other.m_indent );
std::swap( m_os, other.m_os );
}
XmlWriter& startElement( std::string const& name ) {
ensureTagClosed();
newlineIfNecessary();
@@ -105,11 +105,11 @@ namespace Catch {
}
else {
stream() << m_indent << "</" << m_tags.back() << ">\n";
}
}
m_tags.pop_back();
return *this;
}
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
if( !name.empty() && !attribute.empty() ) {
stream() << " " << name << "=\"";
@@ -123,14 +123,14 @@ namespace Catch {
stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
return *this;
}
template<typename T>
XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
if( !name.empty() )
stream() << " " << name << "=\"" << attribute << "\"";
return *this;
}
XmlWriter& writeText( std::string const& text, bool indent = true ) {
if( !text.empty() ){
bool tagWasOpen = m_tagIsOpen;
@@ -142,47 +142,47 @@ namespace Catch {
}
return *this;
}
XmlWriter& writeComment( std::string const& text ) {
ensureTagClosed();
stream() << m_indent << "<!--" << text << "-->";
m_needsNewline = true;
return *this;
}
XmlWriter& writeBlankLine() {
ensureTagClosed();
stream() << "\n";
return *this;
}
private:
std::ostream& stream() {
return *m_os;
}
void ensureTagClosed() {
if( m_tagIsOpen ) {
stream() << ">\n";
m_tagIsOpen = false;
}
}
void newlineIfNecessary() {
if( m_needsNewline ) {
stream() << "\n";
m_needsNewline = false;
}
}
void writeEncodedText( std::string const& text ) {
static const char* charsToEncode = "<&\"";
std::string mtext = text;
std::string::size_type pos = mtext.find_first_of( charsToEncode );
while( pos != std::string::npos ) {
stream() << mtext.substr( 0, pos );
switch( mtext[pos] ) {
case '<':
stream() << "&lt;";
@@ -198,14 +198,14 @@ namespace Catch {
pos = mtext.find_first_of( charsToEncode );
}
stream() << mtext;
}
}
bool m_tagIsOpen;
bool m_needsNewline;
std::vector<std::string> m_tags;
std::string m_indent;
std::ostream* m_os;
};
}
#endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED