From 0df4394a9de4ff7173ff94d40541ca413f74cc1b Mon Sep 17 00:00:00 2001 From: Ralph Marschall Date: Fri, 21 Sep 2018 11:39:06 +0200 Subject: [PATCH] Polish style and comment --- common_files/struct.h | 3 +++ project/metsparser.cpp | 58 ++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/common_files/struct.h b/common_files/struct.h index 6a217b3..7d13aa2 100644 --- a/common_files/struct.h +++ b/common_files/struct.h @@ -57,6 +57,9 @@ struct AmdSec : public dataitem std::string sourceData; // mix:ChangeHistory/mix:ImageProcessing/mix:SourceData for cut-outs int dpi; }; + +// TODO: Refactor AmdSec to AmdSecMix and add AmdSecOdrl. Break the code and compile. + //! structure of a block type struct typeBlock { diff --git a/project/metsparser.cpp b/project/metsparser.cpp index 3965b66..89579a3 100644 --- a/project/metsparser.cpp +++ b/project/metsparser.cpp @@ -106,6 +106,9 @@ void StateParseramdSecState::startElement (const char* const name, const xercesc }; +/** MixContainerNotDefine stores the keys of mandatoryField that have not been found. + Improvement: MixContainerNotDefine should be a set. The value for key is not used. +*/ void StateParseramdSecState::endElement (const char* const name){ CTX.dfMets->set(CTX.amdsec.amdSecId,CTX.amdsec); @@ -519,17 +522,14 @@ private : } - if (CTX.currentItem ==0) - { + if (CTX.currentItem ==0) { //CTX.rootItem = new Item; CTX.rootItem->id = (val1 ? val1 : ""); CTX.rootItem->label = (val3 ? val3 : ""); CTX.rootItem->type = (val2 ? val2 : ""); CTX.rootItem->dmdId = (val4 ? val4 : ""); CTX.currentItem = CTX.rootItem; - } - else - { + } else { Item c; c.id = (val1 ? val1 : ""); c.label = (val3 ? val3 : ""); @@ -552,8 +552,7 @@ class SateParserstructMapArea : public SateParserstructMapRoot{ //cerr << "SateParserstructMapArea :: startElement" << name << endl; const char *val1 = getAttributeValue("FILEID", atts); const char *val2 = getAttributeValue("BEGIN", atts); - if (val1 /*&& val2*/) - { + if (val1 /*&& val2*/) { if ( val2) { CTX.typeblock.block = val2; } @@ -568,15 +567,15 @@ class SateParserstructMapArea : public SateParserstructMapRoot{ void SateParserstructMap::startElement (const char* const name, const xercesc::Attributes &atts ){ //cerr << "SateParserstructMap :: startElement" << name << endl; - CTX.currentItem =0; - //CTX.rootItem =0; + CTX.currentItem = 0; + //CTX.rootItem = 0; std::string val = getAttributeValue("TYPE", atts); - if (val.find("LOGICAL")!=string::npos){ + if (val.find("LOGICAL") != string::npos) { LOGICAL = true; CTX.rootItem = &CTX.rootItemLOGICAL; CTX.currentItem = 0; - }else{ + } else { LOGICAL = false; CTX.rootItem = &CTX.rootItemPHYSICAL; CTX.currentItem = 0; @@ -587,13 +586,14 @@ void SateParserstructMap::startElement (const char* const name, const xercesc::A void SateParserstructMap::endElement (const char* const name){ if ( LOGICAL ) { Item t; - t.id = CTX.rootItem->id; - t.children = CTX.rootItem->children; - t.dmdId =CTX.rootItem->dmdId; - t.label =CTX.rootItem->label; - t.parent =CTX.rootItem->parent; - t.type =CTX.rootItem->type; - t.vectTypeBlock =CTX.rootItem->vectTypeBlock; + t.id = CTX.rootItem->id; + t.children = CTX.rootItem->children; + t.dmdId = CTX.rootItem->dmdId; + t.label = CTX.rootItem->label; + t.parent = CTX.rootItem->parent; + t.type = CTX.rootItem->type; + t.vectTypeBlock = CTX.rootItem->vectTypeBlock; + CTX.dfMets->set("Item",t); //delete CTX.rootItem; }; @@ -608,9 +608,9 @@ StateParserState* SateParserstructMapRoot::getNext(const char* const name){ static struct _onlyOnes { _onlyOnes(std::map& map){ - map["structMap"]= new SateParserstructMap(); - map["div"]= new SateParserstructMapDiv(); - map["area"]= new SateParserstructMapArea(); + map["structMap"] = new SateParserstructMap(); + map["div"] = new SateParserstructMapDiv(); + map["area"] = new SateParserstructMapArea(); } } onlyOnes (map); @@ -631,19 +631,17 @@ StateParserState* StateParserMetsRootState::getNext(const char* const name){ static struct _onlyOnes { _onlyOnes(std::map& map){ - map["mets"]= new StateParserMetsState(); + map["mets"] = new StateParserMetsState(); // structmap - map["structMap"]= new SateParserstructMap(); // sub state machine + map["structMap"] = new SateParserstructMap(); // sub state machine // file -> has his sub state - map["fileSec"]= new StateParserfileSec(); + map["fileSec"] = new StateParserfileSec(); // dmdSec - map["dmdSec"]= new StateParserdmdSecState(); - map["mods"]= new StateParsermodState(); // could be better if children of dmdsec - map["controlfield"]= new StateParsermodStateInventoryMarc("BIBREC_SYS_NUM"); // could be better if children of dmdsec + map["dmdSec"] = new StateParserdmdSecState(); + map["mods"] = new StateParsermodState(); // could be better if children of dmdsec + map["controlfield"] = new StateParsermodStateInventoryMarc("BIBREC_SYS_NUM"); // could be better if children of dmdsec // amd -> has his sub state - map["amdSec"]= new StateParseramdSecState(); - - + map["amdSec"] = new StateParseramdSecState(); } } onlyOnes (map);