本文整理汇总了C++中ConfigParseToConsole类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigParseToConsole类的具体用法?C++ ConfigParseToConsole怎么用?C++ ConfigParseToConsole使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigParseToConsole类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeCommands
void Executive::executeCommands(ConfigParseToConsole configure)
{
//demonstrating each requirment one by one
Display dp;
XmlProcessing::XmlDocument doc(configure.getRepository()->getRoot());
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstarting Requirement 3 and 10 by parsing and thereby writing an XML File/String to corresponding Tree representation";
std::cout << "\n" << std::string(150, '=');
dp.displayToConsole(configure.getRepository()->getRoot(), true);
dp.writeToOutputXML(configure.getRepository()->getRoot(), true);
//Execute Functions:If TA supplies any new XML then he can make neccesary changes
demonstrateAddRoot(dp, doc, "NewRoot");
demonstrateFindByTag(dp, doc, "title");
demonstrateFindByTag(dp, doc, "HelloWorld");
demonstrateFindByNameValue(dp, doc, "tagName", "Tester");
demonstrateFindByNameValue(dp, doc, "InvalidName", "InvalidValue");
demonstrateShowAttribute(dp, doc, "LectureNote");
demonstrateShowChildren(dp, doc, "LectureNote");
demonstrateAddAttribute(dp, doc, "title", "name", "ojas");
demonstrateAddChild(dp, doc, "LectureNote", "comment");
demonstrateAddChild(dp, doc, "LectureNote", "tag");
demonstrateAddChild(dp, doc, "LectureNote", "text");
demonstrateRemoveAttribute(dp, doc, "GreatChildTestTag", "tagName", "Tester");
demonstrateRemoveChild(dp, doc, "author", "TestTag");
doc.findById("").removeChild("LectureNote"); //removing the root from the docElement so that addRoot Functionality can be tested
demonstrateAddRoot(dp, doc, "NewRoot");
demonstrateMoveOperation(dp, doc);
}
示例2: executeForString
void executeForString()
{
//build parser
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
std::string string = makeString();
if (pParser)
{
bool flag = configure.Attach(string, false);
if (!flag)
{
std::cout << "\n could not open file " << string << std::endl;
return;
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
return;
}
// now that parser is built, use it
Executive exec(configure.getRepository()->getRoot());
while (pParser->next())
pParser->parse();
exec.executeCommands(configure);
}
示例3: callParser
WorkResult callParser()
{
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
if (pParser)
{
if (!configure.Attach("../TestFile/nimei.cpp"))
{
std::cout << "\n could not open file ";
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
}
while (pParser->next())
pParser->parse();
std::cout << "\n";
for (std::map<std::string, std::string>::iterator it = configure.getType().begin(); it != configure.getType().end(); it++)
{
std::cout << it->first << " => " << it->second << '\n';
}
return "Parser Done";
}
示例4: main
int main(int argc, char* argv[])
{
std::cout << "\n Testing Parser class\n "
<< std::string(22,'=') << std::endl;
// collecting tokens from files, named on the command line
if(argc < 2)
{
std::cout
<< "\n please enter name of file to process on command line\n\n";
return 1;
}
for(int i=1; i<argc; ++i)
{
std::cout << "\n Processing file " << argv[i];
std::cout << "\n " << std::string(16 + strlen(argv[i]),'-');
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
try
{
if(pParser)
{
if(!configure.Attach(argv[i]))
{
std::cout << "\n could not open file " << argv[i] << std::endl;
continue;
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
return 1;
}
// now that parser is built, use it
while(pParser->next())
pParser->parse();
std::cout << "\n\n";
}
catch(std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
std::cout << "\n\n";
//configure.show();
}
}
开发者ID:DavidNingGithub,项目名称:Performance-Assessment-Framework-of-Remote-Server,代码行数:53,代码来源:Parser.cpp
示例5: main
int main(int argc, char* argv[])
{
Util::Title("Testing Parser Class", '=');
putline();
// collecting tokens from files, named on the command line
if(argc < 2)
{
std::cout
<< "\n please enter name of file to process on command line\n\n";
return 1;
}
for(int i=1; i<argc; ++i)
{
std::string fileSpec = FileSystem::Path::getFullFileSpec(argv[i]);
std::string msg = "Processing file" + fileSpec;
Util::title(msg);
putline();
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
try
{
if(pParser)
{
if(!configure.Attach(argv[i]))
{
std::cout << "\n could not open file " << fileSpec << std::endl;
continue;
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
return 1;
}
// now that parser is built, use it
while(pParser->next())
pParser->parse();
std::cout << "\n";
}
catch(std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
}
std::cout << "\n";
system("pause");
}
示例6: parser
int parser(FileMgr::files& myfiles)
{
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
configure.accessRepo()->initializerootvector();
for (auto file : myfiles) {
configure.accessRepo()->setfilename(FileSystem::Path::getName(file));
try {
if (pParser) {
if (!configure.Attach(file))
{
std::cout << "\n could not open file " << file << std::endl;
continue;
}
}
else {
std::cout << "\n\n Parser not built\n\n";
return 1;
}
// now that parser is built, use it
while (pParser->next())
pParser->parse();
}
catch (std::exception& ex) {
std::cout << "\n\n " << ex.what() << "\n\n";
}
}
//configure.accessRepo()->walkthrough();
configure.accessRepo()->simplify();
configure.accessRepo()->sort();
configure.accessRepo()->detectmatch();
return 0;
}
示例7: parseFile
void Parser::parseFile(std::string pFileName)
{
std::cout << "\n Testing Parser class\n "
<< std::string(22, '=') << std::endl;
// collecting tokens from files, named on the command line
if (pFileName.length() == 0 )
{
std::cout
<< "\n Wrong file input\n\n";
return;
}
std::cout << "\n Processing file " << pFileName;
std::cout << "\n " << std::string(16 , '-');
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
try
{
if (pParser)
{
if (!configure.Attach(pFileName))
{
std::cout << "\n could not open file " << pFileName << std::endl;
return;
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
return;
}
// now that parser is built, use it
while (pParser->next())
pParser->parse();
std::cout << "\n\n";
}
catch (std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
std::cout << "\n\n";
//configure.show();
}
开发者ID:DavidNingGithub,项目名称:Performance-Assessment-Framework-of-Remote-Server,代码行数:49,代码来源:Parser.cpp
示例8: main
int main(int argc, char* argv[])
{
//collecting tokens from files, named on the command line
if (argc < 2)
{
std::cout<< "\n please enter name of file to process on command line\n\n";
return 1;
}
FileManager fileManager;
std::vector<std::string> patterns = { "*.h" , "*.cpp" };
std::vector<std::string> files = fileManager.getFiles("..//", patterns);
for (int i = 1; i<argc; ++i)
{
std::string fileSpec = FileSystem::Path::getFullFileSpec(argv[i]);
std::string msg = "Processing file" + fileSpec;
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
MetricAnalyzer *test = new MetricAnalyzer;
try {
if (pParser) {
if (!configure.Attach(argv[i]))
{
std::cout << "\n could not open file " << fileSpec << std::endl;
continue;
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
return 1;
}
while (pParser->next())
{
pParser->parse();
}
std::cout << "\n";
configure.printTree();
test->setRoot(configure.getRoot());
test->getComplexity(test->getRoot());
test->getComplexity(test->getRoot());
}
catch (std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
}
}
示例9: system
/* Will Analyze a file with path "filename".
Analyze -> Parse, Print AST, Print Scopes */
void AnalyzeSingleFile::analyze(std::string filename)
{
if (VERBOSE) { std::cout << "\n [VERBOSE] : Validating File : " << filename << "\n"; }
std::string fileSpec = FileSystem::Path::getFullFileSpec(filename);
if (!fileExists(fileSpec))
{
std::cout << "\n Specified file Not found";
std::cout << "\n Are you sure file \"" << fileSpec << "\" exists ?";
std::cout << "\n ";
system("pause");
return;
}
ConfigParseToConsole configure;
configure.setVerbose(VERBOSE);
Parser* pParser = configure.Build();
try {
if (pParser) { if (!configure.Attach(fileSpec)) { std::cout << "\n could not open file" << fileSpec << "\n "; } }
else { std::cout << "\n Parser not built \n "; }
while (pParser->next())
pParser->parse();
if (_ShowResult) { StringHelper::Title("\n File : " + fileSpec, '='); }
Repository* repo = Repository::getInsance();
element* rootElem = repo->getTree()->getRoot(); // Retriving Root Element to set its linecount and Complexity.
rootElem->lineCountEnd = repo->lineCount(); // Set Line count(s)
rootElem->lineCount = rootElem->lineCountEnd - rootElem->lineCountBegin + 1;
rootElem->complexity = repo->getTree()->getComplexity(rootElem); // Set Complexity
if (_ShowResult) { printTree(repo); } // Printing AST on the command prompt
if (_ShowResult) { printFunctions(repo); } // Printing file scopes on the command prompt
repo->getTable()->addEntry("EOS", "namespace EOS"); // Add Namespace EOS for Global Namespace
setTypeTableFields(repo, fileSpec); // Set some values in TypeTable (Filename and Namespace)
setTable(repo); // Set the typeTable in Metrics to the typetable obtained from Repository
// Doing this will prevent keeping entire repo instance in the memory and just hold the partial typetable.
if (_ShowResult) {
printTable(repo); // Printing the TypeTable
std::cout << "\n";
}
}
catch (std::exception& ex)
{
std::cout << "\n\n [EXCEPTION] : " << ex.what() << "\n\n";
}
}
示例10: main
int main(int argc, char* argv[])
{
Util::Title("Testing Parser Class", '=');
putline();
// collecting tokens from files, named on the command lines
std::string path = "C:\\Users\\Sruthi Guvvala\\Desktop\\Project2HelperCode\\Project2HelperCode\\Parser";
std::vector<std::string> a = FileSystem::Directory::getFiles(path, "*.cpp");
std::vector<std::string>::iterator iter = a.begin();
//std::cout << *iter;
while (iter != a.end())
{
std::string fileSpec = path + "\\" + *iter;
std::cout << fileSpec;
std::string msg = "Processing file" + fileSpec;
Util::title(msg);
putline();
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
try
{ if(pParser)
{
if(!configure.Attach(fileSpec))
{
std::cout << "\n could not open file " << fileSpec << std::endl;
continue;
}}
else
{
std::cout << "\n\n Parser not built\n\n";
return 1;
}
while (pParser->next())
{
pParser->parse();
}
std::cout << "\n";
configure.printTree();
}
catch(std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}iter++;
std::cout << "\n";
}
}
示例11: main
int main(int argc, char* argv[])
{
std::cout << "\n Testing ConfigureParser module\n "
<< std::string(32, '=') << std::endl;
for (int i = 1; i<argc; ++i)
{
std::cout << "\n Processing file " << argv[i];
std::cout << "\n " << std::string(16 + strlen(argv[i]), '-');
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
try
{
if (pParser)
{
while(configure.Attach(argv[i]))
{
std::cout << "\n could not open file " << argv[i] << std::endl;
int j = 0;
switch (j){
case 0:
std::cout << "\n case 0" << std::endl;
break;
default:
break;
}
continue;
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
return 1;
}
}
catch (std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
std::cout << "\n\n";
}
}
示例12: main
int main(int argc, char* argv[])
{
std::cout << "\n Testing ConfigureParser module\n "
<< std::string(32,'=') << std::endl;
// collecting tokens from files, named on the command line
if(argc < 2)
{
std::cout
<< "\n please enter name of file to process on command line\n\n";
return 1;
}
for(int i=1; i<argc; ++i)
{
std::cout << "\n Processing file " << argv[i];
std::cout << "\n " << std::string(16 + strlen(argv[i]),'-');
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
try
{
if(pParser)
{
if(!configure.Attach(argv[i]))
{
std::cout << "\n could not open file " << argv[i] << std::endl;
continue;
}
}
else
{
std::cout << "\n\n Parser not built\n\n";
return 1;
}
// now that parser is built, use it
while(pParser->next())
pParser->parse();
std::cout << "\n\n";
}
catch(std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
////
// std::cout << "\n Processing file for Queued Outputs " << argv[i];
// std::cout << "\n " << std::string(35 + strlen(argv[i]),'-');
//
// ConfigParseToQueue Qconfigure;
// pParser = Qconfigure.Build();
// try
// {
// if(pParser)
// {
// if(!Qconfigure.Attach(argv[i]))
// {
// std::cout << "\n could not open file " << argv[i] << std::endl;
// continue;
// }
// }
// else
// {
// std::cout << "\n\n Parser not built\n\n";
// return 1;
// }
// // now that parser is built, use it
//
// while(pParser->next())
// pParser->parse();
// std::cout << "\n\n";
// }
// catch(std::exception& ex)
// {
// std::cout << "\n\n " << ex.what() << "\n\n";
// }
// std::queue<std::string>* pQueue = Qconfigure.GetQueue();
// size_t len = pQueue->size();
// for(size_t i=0; i<len; ++i)
// {
// std::cout << "\n " << pQueue->front();
// pQueue->pop();
// }
// std::cout << "\n\n";
}
}
示例13: main
int main(int argc, char *argv[])
{
title("Testing XmlDocument class");
std::vector<std::pair<std::string, std::string>> vectorAttributePair;
std::vector<std::shared_ptr<AbstractXmlElement>> vectorSharedPtr;
// build parser first
ConfigParseToConsole configure;
Parser* pParser = configure.Build();
configure.Attach(argv[1]);
// now that parser is built, use it
while (pParser->next())
pParser->parse();
std::shared_ptr < AbstractXmlElement > pDocElement;
XmlProcessing::XmlDocument doc(configure.getRepository()->getRoot());
pDocElement = doc.getRoot();
//test and then display each method one by one
vectorSharedPtr = doc.findByNameAndValue("course","CSE681").select();
std::cout << "\n\n" << "Displaying Functionality of Method:'findByNameAndValue' and Method:'select'" << "\n";
std::cout << "\n\n" << "Query is:Find Collection of Elements with Name-Value Pair: 'course = CSE681'" << "\n" << "XML Portion found with specified ID is:";
for (auto elem : vectorSharedPtr)
{
std::cout << "\n" << elem->toString() << "\n" << std::string(60, '-');
}
//On using the function select found Vector is moved
vectorSharedPtr = doc.findById("LectureNote").select();
std::cout << "\n\n" << "Displaying Functionality of Method:'findById' and Method: 'select'" << "\n";
std::cout << "\n\n" << "Query is:Find Collection of Elements with tag: LectureNote"<<"\n"<<"XML Portion found with specified ID is:";
for (auto elem : vectorSharedPtr)
{
std::cout << "\n" << elem->toString() << "\n" << std::string(60, '-');
}
std::cout << "\n\n" << "Displaying Functionality of Method:'addAttribute'" << "\n";
std::cout << "\n\n" << "Query is: Add attribute with Name-Value: 'name = ojas' in tag: author" << "\n" << "Modified XML is:";
doc.findById("author").addAttribute("name","ojas");
std::cout << "\n\n" << pDocElement->toString() << "\n"<<std::string(60, '-');
std::cout << "\n\n" << "Displaying Functionality of Method:'removeAttribute'" << "\n";
std::cout << "\n\n" << "Query is: remove attribute with Name-Value: 'name = ojas' in tag: author" << "\n" << "Modified XML is:";
doc.findById("author").removeAttribute("name", "ojas");
std::cout << "\n\n" << pDocElement->toString() << "\n" << std::string(60, '-');
std::cout << "\n\n" << "Displaying Functionality of Method:'addChild'" << "\n";
std::cout << "\n\n" << "Query is: Add child with tag: 'children' in parent tag: author" << "\n" << "Modified XML is:";
std::shared_ptr < AbstractXmlElement > sharedPtr = makeTaggedElement("children");
doc.findById("author").addChild(sharedPtr);
std::cout << "\n\n" << pDocElement->toString() << "\n" << std::string(60, '-');
std::cout << "\n\n" << "Displaying Functionality of Method:'removeChild'" << "\n";
std::cout << "\n\n" << "Query is: Remove child with tag: 'children' in parent tag: author" << "\n" << "Modified XML is:";
doc.findById("author").removeChild("children");
std::cout << "\n\n" << pDocElement->toString() <<"\n"<< std::string(60, '-');
std::cout << "\n\n" << "Displaying Functionality of Method:'getAttributePairVector'" << "\n";
std::cout << "\n\n" << "Query is: get attributePair by giving pointer to the element of Tag: LectureNote";
vectorAttributePair = doc.getAttributePairVector(vectorSharedPtr[0]);
std::cout << "\n""\n" << "Following Name-Value Attribute Pair Found:"<< "\n";
for (auto elem : vectorAttributePair)
{
std::cout << elem.first.c_str() << " = " << elem.second.c_str() << "\n";
}
std::cout << std::string(60, '-');
std::cout << "\n\n" << "Displaying Functionality of Method:'getChildrenVector'" << "\n";
std::cout << "\n\n" << "Query is: get childrens by giving pointer to the element of Tag: LectureNote";
for (auto elem : doc.getChildrenVector(vectorSharedPtr[0]))
{
std::cout << elem->value() << "\n";
}
std::cout<<std::string(60, '-');
std::cout << "\n\n" << "Displaying Functionality of Method:'addRoot'" << "\n";
std::cout << "\n\n" << "Query is: adding root after deleting all the childs"<<"\n"<<"New Root Formed with Tagged element: 'newchild' is:";
doc.findById("").removeChild("LectureNote");
doc.findById("").removeChild("xml declaration");
doc.findById("").removeChild("xml declaration");
doc.findById("").removeChild("XML test case");
doc.addRoot("newchild");
std::cout << "\n\n" << doc.getRoot()->toString() <<"\n"<< std::string(60, '-');
return 0;
}