Cosmetics
This commit is contained in:
parent
fa3f58d847
commit
fa5b58dfe5
7 changed files with 30 additions and 32 deletions
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "Assignment.h"
|
||||
#include "annotation.h"
|
||||
#include "expression.h"
|
||||
#include "context.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -25,23 +25,22 @@
|
|||
*/
|
||||
|
||||
#include "Assignment.h"
|
||||
#include "annotation.h"
|
||||
|
||||
|
||||
|
||||
void Assignment::add_annotations(AnnotationList *annotations)
|
||||
void Assignment::addAnnotations(AnnotationList *annotations)
|
||||
{
|
||||
for (AnnotationList::iterator it = annotations->begin();it != annotations->end();it++) {
|
||||
this->annotations.insert(std::pair<const std::string, Annotation *>((*it).getName(), &(*it)));
|
||||
for (auto &annotation : *annotations) {
|
||||
this->annotations.insert(std::make_pair(annotation.getName(), &annotation));
|
||||
}
|
||||
}
|
||||
|
||||
bool Assignment::has_annotations() const
|
||||
bool Assignment::hasAnnotations() const
|
||||
{
|
||||
return !annotations.empty();
|
||||
}
|
||||
|
||||
const Annotation * Assignment::annotation(const std::string &name) const
|
||||
{
|
||||
AnnotationMap::const_iterator it = annotations.find(name);
|
||||
return it == annotations.end() ? NULL : (*it).second;
|
||||
auto found = annotations.find(name);
|
||||
return found == annotations.end() ? nullptr : found->second;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "comment.h"
|
||||
#include "expression.h"
|
||||
#include "annotation.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
@ -219,6 +220,6 @@ void CommentParser::addParameter(const char *fulltext, FileModule *root_module)
|
|||
shared_ptr<Expression> expr(new Literal(ValuePtr(groupList[i].commentString)));
|
||||
annotationList->push_back(Annotation("Group", expr));
|
||||
}
|
||||
assignment.add_annotations(annotationList);
|
||||
assignment.addAnnotations(annotationList);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "ModuleInstantiation.h"
|
||||
#include "expression.h"
|
||||
#include "function.h"
|
||||
#include "annotation.h"
|
||||
|
||||
LocalScope::LocalScope()
|
||||
{
|
||||
|
|
@ -32,7 +33,7 @@ std::string LocalScope::dump(const std::string &indent) const
|
|||
dump << m.second->dump(indent, m.first);
|
||||
}
|
||||
for (const auto &ass : this->assignments) {
|
||||
if (ass.has_annotations()) {
|
||||
if (ass.hasAnnotations()) {
|
||||
const Annotation *group = ass.annotation("Group");
|
||||
if (group != NULL) dump << group->dump();
|
||||
const Annotation *Description = ass.annotation("Description");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "module.h"
|
||||
#include "modcontext.h"
|
||||
#include "annotation.h"
|
||||
|
||||
ParameterObject::ParameterObject()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ ParameterSet::~ParameterSet()
|
|||
|
||||
}
|
||||
|
||||
void ParameterSet::getParameterSet(string filename){
|
||||
|
||||
fstream myfile;
|
||||
void ParameterSet::getParameterSet(const std::string &filename)
|
||||
{
|
||||
std::fstream myfile;
|
||||
myfile.open (filename);
|
||||
// send your JSON above to the parser below, but populate ss first
|
||||
if(myfile.is_open()){
|
||||
|
|
@ -27,13 +27,13 @@ void ParameterSet::getParameterSet(string filename){
|
|||
myfile.close();
|
||||
}
|
||||
|
||||
void ParameterSet::writeParameterSet(string filename){
|
||||
void ParameterSet::writeParameterSet(const std::string &filename){
|
||||
if(root.empty()){
|
||||
return;
|
||||
}
|
||||
|
||||
fstream myfile;
|
||||
myfile.open(filename,ios::out);
|
||||
std::fstream myfile;
|
||||
myfile.open(filename, std::ios::out);
|
||||
// send your JSON above to the parser below, but populate ss first
|
||||
if(myfile.is_open()){
|
||||
try{
|
||||
|
|
@ -47,14 +47,14 @@ void ParameterSet::writeParameterSet(string filename){
|
|||
myfile.close();
|
||||
}
|
||||
|
||||
void ParameterSet::applyParameterSet(FileModule *fileModule,string setName)
|
||||
void ParameterSet::applyParameterSet(FileModule *fileModule, const std::string &setName)
|
||||
{
|
||||
try{
|
||||
if (fileModule == NULL ||root.empty()) {
|
||||
return;
|
||||
}
|
||||
ModuleContext ctx;
|
||||
string path="SET."+setName;
|
||||
std::string path="SET."+setName;
|
||||
for (AssignmentList::iterator it = fileModule->scope.assignments.begin();it != fileModule->scope.assignments.end();it++) {
|
||||
|
||||
for(pt::ptree::value_type &v : root.get_child(path)){
|
||||
|
|
|
|||
|
|
@ -5,29 +5,25 @@
|
|||
#include "FileModule.h"
|
||||
#include "modcontext.h"
|
||||
|
||||
#include<map>
|
||||
|
||||
#include <map>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ParameterSet
|
||||
{
|
||||
|
||||
protected:
|
||||
pt::ptree root;
|
||||
typedef map<string,pt::ptree::value_type> Parameterset;
|
||||
Parameterset parameterSet;
|
||||
pt::ptree root;
|
||||
typedef std::map<std::string, pt::ptree::value_type> Parameterset;
|
||||
Parameterset parameterSet;
|
||||
|
||||
public:
|
||||
ParameterSet();
|
||||
~ParameterSet();
|
||||
void getParameterSet(string filename);
|
||||
void writeParameterSet(string filename);
|
||||
void applyParameterSet(FileModule *fileModule,string setName);
|
||||
ParameterSet();
|
||||
~ParameterSet();
|
||||
void getParameterSet(const std::string &filename);
|
||||
void writeParameterSet(const std::string &filename);
|
||||
void applyParameterSet(FileModule *fileModule, const std::string &setName);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue