Skip to content

Commit

Permalink
Revert clang-format related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfgc committed Sep 30, 2021
1 parent 9b2e2fb commit b5571ec
Show file tree
Hide file tree
Showing 9 changed files with 1,851 additions and 1,922 deletions.
2,565 changes: 1,231 additions & 1,334 deletions src/QMCTools/ppconvert/src/NLPPClass.cc

Large diffs are not rendered by default.

129 changes: 73 additions & 56 deletions src/QMCTools/ppconvert/src/XMLWriterClass2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
//
// File created by: Paul R. C. Kent, kentpr@ornl.gov, Oak Ridge National Laboratory
//////////////////////////////////////////////////////////////////////////////////////





#include "XMLWriterClass2.h"
Expand All @@ -18,26 +21,27 @@

XMLAttribute::XMLAttribute(std::string name, std::string content)
{
Name = name;
Name = name;
Content = content;
}

XMLAttribute::XMLAttribute(const XMLAttribute& attr)
{
Name = attr.Name;
Content = attr.Content;
XMLAttribute::XMLAttribute (const XMLAttribute &attr)
{
Name = attr.Name;
Content = attr.Content;
}


void XMLAttribute::Write(std::string& out)
void
XMLAttribute::Write(std::string &out)
{
std::stringstream str;
str << Name << "=\"" << Content << "\"";
out = str.str();
}


XMLElement::XMLElement(const XMLElement& elem)
XMLElement::XMLElement(const XMLElement &elem)
{
Attributes = elem.Attributes;
Children = elem.Children;
Expand All @@ -46,170 +50,183 @@ XMLElement::XMLElement(const XMLElement& elem)
Level = elem.Level;
}

void XMLElement::Indent(std::ostream& out)
void
XMLElement::Indent(std::ostream &out)
{
for (int i = 0; i < Level; i++)
for (int i=0; i<Level; i++)
out << " ";
}


void XMLElement::Write(std::ostream& out)
void
XMLElement::Write(std::ostream &out)
{
Indent(out);
out << "<" << Name;
int lineCount = Name.size() + 1;
for (int i = 0; i < Attributes.size(); i++)
{
int lineCount = Name.size()+1;
for (int i=0; i<Attributes.size(); i++) {
out << " ";
std::string str;
Attributes[i]->Write(str);
if (lineCount + str.size() + 2 * Level > 73)
{
if (lineCount + str.size() + 2*Level > 73) {
out << "\n";
Indent(out);
Indent (out);
out << " ";
lineCount = 1;
}
lineCount += str.size();
out << str;
}
int numLines = 0;
for (int i = 0; i < Content.size(); i++)
for (int i=0; i<Content.size(); i++)
numLines += (Content[i] == '\n');

if (Content == "" && Children.size() == 0)
if (Content == "" && Children.size()==0)
out << "/>\n";
else
{
else {
out << ">";
if (numLines > 0 || Children.size() > 0)
out << "\n";
out << Content;
for (int i = 0; i < Children.size(); i++)
for (int i=0; i<Children.size(); i++)
Children[i]->Write(out);
if (numLines > 0 || Children.size() > 0)
if (numLines > 0 || Children.size()>0)
Indent(out);
out << "</" << Name << ">\n";
}
}



void XMLElement::AddContent(std::vector<double>& data)
void
XMLElement::AddContent(std::vector<double> &data)
{
std::stringstream str;
str.setf(std::ios_base::scientific, std::ios_base::floatfield);
str << std::setprecision(14);
for (int i = 0; i < data.size(); i++)
{
if ((i % 3 == 0))
for (int i=0; i<data.size(); i++) {
if ((i%3 == 0))
Indent(str);
str.width(22);
str << data[i];
if ((i % 3) == 2)
if ((i%3) == 2)
str << "\n";
}
if ((data.size() % 3) != 0)
str << "\n";
if ((data.size()%3) != 0)
str << "\n";
Content += str.str();
}


bool XMLWriterClass::StartDocument(std::string fname, std::string version, std::string encoding, std::string standalone)

bool
XMLWriterClass::StartDocument(std::string fname, std::string version,
std::string encoding, std::string standalone)
{
Out.open(fname.c_str(), std::ofstream::out | std::ofstream::trunc);
Out.open (fname.c_str(),std::ofstream::out | std::ofstream::trunc);
if (!Out.is_open())
return false;
if (version == "")
version = "1.0";
if (encoding == "")
encoding = "UTF-8";

Out << "<?xml version=\"" << version << "\" encoding=\"" << encoding << "\"?>\n";

Out << "<?xml version=\"" << version
<< "\" encoding=\"" << encoding << "\"?>\n";

return true;
}

bool XMLWriterClass::EndDocument()
bool
XMLWriterClass::EndDocument()
{
if (Elements.size() <= 0)
if (Elements.size() <=0)
return false;
Elements[0]->Write(Out);
return true;
}

bool XMLWriterClass::StartElement(std::string name)
bool
XMLWriterClass::StartElement(std::string name)
{
int level = Elements.size();

auto elem = std::make_shared<XMLElement>(name, level);
if (level > 0)
Elements.back()->AddElement(elem);
Elements.back()->AddElement (elem);
Elements.push_back(elem);
return true;
}

bool XMLWriterClass::EndElement()
bool
XMLWriterClass::EndElement()
{
if (Elements.size() > 1)
Elements.pop_back();
return true;
}

bool XMLWriterClass::FullEndElement()
bool
XMLWriterClass::FullEndElement()
{
Elements.pop_back();
return true;
}

bool XMLWriterClass::WriteAttribute(std::string name, std::string content)
bool
XMLWriterClass::WriteAttribute (std::string name, std::string content)
{
auto attr = std::make_shared<XMLAttribute>(name, content);
Elements.back()->AddAttribute(attr);
Elements.back()->AddAttribute (attr);
return true;
}

bool XMLWriterClass::WriteAttribute(std::string name, double val, bool scientific)
bool
XMLWriterClass::WriteAttribute (std::string name, double val, bool scientific)
{
std::stringstream content;
if (scientific)
{
if (scientific) {
content.setf(std::ios_base::scientific, std::ios_base::floatfield);
content << std::setprecision(14);
}
content << val;
auto attr = std::make_shared<XMLAttribute>(name, content.str());
Elements.back()->AddAttribute(attr);
Elements.back()->AddAttribute (attr);
return true;
}

bool XMLWriterClass::WriteAttribute(std::string name, int val)
bool
XMLWriterClass::WriteAttribute (std::string name, int val)
{
std::stringstream content;
content << val;
auto attr = std::make_shared<XMLAttribute>(name, content.str());
Elements.back()->AddAttribute(attr);
Elements.back()->AddAttribute (attr);
return true;
}

bool XMLWriterClass::WriteData(std::vector<double> data)
bool
XMLWriterClass::WriteData(std::vector<double> data)
{
Elements.back()->AddContent(data);
Elements.back()->AddContent (data);
return true;
}

bool XMLWriterClass::WriteData(std::string data)
bool
XMLWriterClass::WriteData(std::string data)
{
Elements.back()->AddContent(data);
Elements.back()->AddContent (data);
return true;
}


bool XMLWriterClass::WriteElement(std::string name, std::vector<double> data)
bool
XMLWriterClass::WriteElement (std::string name, std::vector<double> data)
{
int level = Elements.size();
auto elem = std::make_shared<XMLElement>(name, level);
elem->AddContent(data);
elem->AddContent (data);
if (level > 0)
Elements.back()->AddElement(elem);
Elements.back()->AddElement (elem);
return true;
}

8 changes: 4 additions & 4 deletions src/QMCTools/ppconvert/src/common/CubicSplineCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ class CubicSplineCommon
/// Trivial constructor
CubicSplineCommon()
{
UpToDate = 0;
NumParams = 0;
UpToDate = 0;
NumParams = 0;
StartDeriv = 0;
EndDeriv = 0;
grid = NULL;
EndDeriv = 0;
grid = NULL;
}
};

Expand Down
Loading

0 comments on commit b5571ec

Please sign in to comment.