Skip to content

Commit

Permalink
Polish code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ra1phM committed Sep 21, 2018
1 parent 8bf773a commit 2263293
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions project/metsparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class StateParserRootamdSecState : public StateParserMetsRootState{
virtual StateParserState* getNext(const char* const name);
};

/** This parser handles the root amdSec element.
*/
class StateParseramdSecState : public StateParserRootamdSecState{
virtual void startElement (const char* const name, const xercesc::Attributes &atts );
virtual void endElement (const char* const name);
Expand Down Expand Up @@ -79,13 +81,16 @@ class StateEmptyCheck : public StateParserScanResolution{
};
};


/** This parser handles the root amdSec element.
*/
void StateParseramdSecState::startElement (const char* const name, const xercesc::Attributes &atts ){
const char *val = getAttributeValue("ID", atts);
if (val!=0) {
CTX.amdsec.amdSecId = val;
}



if ( CTX.flagMix ) {
CTX.mandatoryField.insert("scannerManufacturer");
CTX.mandatoryField.insert("scannerModelName");
Expand Down Expand Up @@ -245,32 +250,31 @@ class StateParsermodStateTitleInfoInventory:public StateParsermodState{
public:
StateParsermodStateTitleInfoInventory(){};

StateParserState* getNext(const char* const name){
static std::map<string,StateParserMetsRootState*> map;
static StateParserState* root = this;

StateParserState* ret=root;

static struct _onlyOnes {
_onlyOnes(std::map<string,StateParserMetsRootState*>& map){
//static int i = 0;
//std::cerr << "Only Ones :"<< ++i << std::endl;
map["title"] = new StateParsermodStateInventory("title");
map["nonSort"] = new StateTitleState(" ");
map["subTitle"] = new StateParsermodStateInventory("subTitle");
map["partNumber"] = new StateParsermodStateInventory("partNumber");
}
} onlyOnes (map);
StateParserState* getNext(const char* const name) {
static std::map<string,StateParserMetsRootState*> map;
static StateParserState* root = this;

if (CTX.inventory.isActif()){
std::map<string,StateParserMetsRootState*>::iterator it = map.find(name);
if ( it != map.end()) ret = (*it).second;
};
StateParserState* ret=root;

static struct _onlyOnes {
_onlyOnes(std::map<string,StateParserMetsRootState*>& map){
//static int i = 0;
//std::cerr << "Only Ones :"<< ++i << std::endl;
map["title"] = new StateParsermodStateInventory("title");
map["nonSort"] = new StateTitleState(" ");
map["subTitle"] = new StateParsermodStateInventory("subTitle");
map["partNumber"] = new StateParsermodStateInventory("partNumber");
}
} onlyOnes (map);

return ret;
if (CTX.inventory.isActif()){
std::map<string,StateParserMetsRootState*>::iterator it = map.find(name);
if ( it != map.end()) ret = (*it).second;
};

return ret;

};
};

};

Expand Down

0 comments on commit 2263293

Please sign in to comment.