本文整理汇总了C++中Display::displayToConsole方法的典型用法代码示例。如果您正苦于以下问题:C++ Display::displayToConsole方法的具体用法?C++ Display::displayToConsole怎么用?C++ Display::displayToConsole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Display
的用法示例。
在下文中一共展示了Display::displayToConsole方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: demonstrateShowChildren
void Executive::demonstrateShowChildren(Display dp, XmlProcessing::XmlDocument &doc, const std::string parent)
{
//demonstrates requirment and then send the output to display class
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 8 provide a facility to return a std::vector of pointers to all the children of a specified element.";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Input is Pointer to Element: " << parent << "\n";
std::vector<std::shared_ptr<AbstractXmlElement>> vectorSharedPtr;
vectorSharedPtr = doc.findById(parent).select();
if (vectorSharedPtr.size() > 0)
{
dp.displayToConsole(doc.getChildrenVector(vectorSharedPtr[0]));
dp.displayToConsole(doc.getChildrenVector(vectorSharedPtr[0]), parent);
}
else
std::cout << "\n"<<"Tag: " << parent << " is not found in XML";
}
示例3: demonstrateAddChild
void Executive::demonstrateAddChild(Display dp, XmlProcessing::XmlDocument &doc, const std::string parent, const std::string option)
{
bool displayFlag = false;
std::shared_ptr<AbstractXmlElement> sharedPtr;
if (option == "comment")
{
//demonstrates requirment of add child by adding comment element
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 7 by adding Child Element to any Element in the tree that can hold child references found by ID or Tag.";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Query is: Add Comment Element: 'My Comment' to the parent tag: " + parent + "" << "\n";
sharedPtr = makeCommentElement("My Comment"); //making the pointer of comment element
displayFlag = doc.findById(parent).addChild(sharedPtr);
dp.displayToConsole(pDocElement_, displayFlag, parent);
dp.writeToOutputXML(pDocElement_, displayFlag);
}
else if (option == "tag")
{
//demonstrates requirment of add child by adding tagged element
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n"<< "Demonstrating Requirement 7 by adding Child Element to any Element in the tree that can hold child references found by ID or Tag.";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Query is: Add Tagged Element with tag: 'NewChild' and Name,Value Pair:'NewChildName = NewChildValue' to the parent tag: " + parent + "." << "\n";
sharedPtr = makeTaggedElement("NewChild");
sharedPtr->addAttrib("NewChildName", "NewChildValue");//making the pointer of tagged element
displayFlag = doc.findById(parent).addChild(sharedPtr);
dp.displayToConsole(pDocElement_, displayFlag, parent);
dp.writeToOutputXML(pDocElement_, displayFlag);
}
else if (option == "text")
{
//demonstrates requirment of add child by adding text element
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 7 by adding Child Element to any Element in the tree that can hold child references found by ID or Tag.";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Query is: Add Text Element with Text: 'NewChildText' to the parent tag: "+ parent +"."<<"\n";
sharedPtr = makeTextElement("NewChildText");//making the pointer of text element
displayFlag = doc.findById(parent).addChild(sharedPtr);
dp.displayToConsole(pDocElement_, displayFlag, parent);
dp.writeToOutputXML(pDocElement_, displayFlag);
}
}
示例4: demonstrateFindByTag
void Executive::demonstrateFindByTag( Display dp, XmlProcessing::XmlDocument &doc, const std::string tag)
{
//demonstrates requirment by finding element using ID/Tag
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n"<< "Demonstrating Requirement 6 by finding pointers to the a collection of elements that have the tag: "+ tag +"";
std::cout << "\n" << std::string(150, '=');
std::vector<std::shared_ptr<AbstractXmlElement>> vectorSharedPtr;
vectorSharedPtr = doc.findById(tag).select();
dp.displayToConsole(vectorSharedPtr, tag);
}
示例5: demonstrateFindByNameValue
void Executive::demonstrateFindByNameValue(Display dp, XmlProcessing::XmlDocument &doc, const std::string name, const std::string value)
{
//demonstrates requirment by finding element using name value pair
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 5 by finding pointer to the element that have the specified name and value pair";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Query is: Find with name and value pair as: '" + name + " = " + value + "'"<<"\n";
std::vector<std::shared_ptr<AbstractXmlElement>> vectorSharedPtr;
vectorSharedPtr = doc.findByNameAndValue(name, value).select();
dp.displayToConsole(vectorSharedPtr, name, value);
}
示例6: demonstrateRemoveChild
void Executive::demonstrateRemoveChild(Display dp, XmlProcessing::XmlDocument &doc, const std::string parent, const std::string elementToBeDeleted)
{
//demonstrates requirment of remove child and then send the output to display class
bool displayFlag = false;
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 7 by removing Child Element from any Element in the tree that can hold child references found by ID or Tag.";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Query is: :Remove Child Element with Tag: " + elementToBeDeleted + " from the parent tag: "+parent+"."<<"\n";
displayFlag = doc.findById(parent).removeChild(elementToBeDeleted);
dp.displayToConsole(pDocElement_, displayFlag, parent);
dp.writeToOutputXML(pDocElement_, displayFlag);
}
示例7: demonstrateAddAttribute
void Executive::demonstrateAddAttribute(Display dp, XmlProcessing::XmlDocument &doc, const std::string parent, std::string name, const std::string value)
{
//demonstrates requirment of add child by adding attribute
bool displayFlag = false;
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 9 by adding name and value pair that supports attributes";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n""\n" << "Query is: Add Name-Value Pair: '" << name << " = " << value << "' to Tag: " << parent << "\n";
displayFlag = doc.findById(parent).addAttribute(name,value);
dp.displayToConsole(pDocElement_, displayFlag, parent);
dp.writeToOutputXML(pDocElement_, displayFlag);
}
示例8: demonstrateRemoveAttribute
void Executive::demonstrateRemoveAttribute(Display dp, XmlProcessing::XmlDocument &doc, const std::string parent, const std::string name, const std::string value)
{
//demonstrates requirment of remove attribute and then send the output to display class
bool displayFlag = false;
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 9 by removing name and value pair that supports attributes";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Query is: Remove Child Attribute with Name-Value Pair: '" + name + " = " + value + "' from the tag: " + parent + "." << "\n";
displayFlag = doc.findById(parent).removeAttribute(name, value);
dp.displayToConsole(pDocElement_, displayFlag, parent);
dp.writeToOutputXML(pDocElement_, displayFlag);
}
示例9: demonstrateShowAttribute
void Executive::demonstrateShowAttribute(Display dp, XmlProcessing::XmlDocument &doc,const std::string tag)
{
//demonstrates requirment and then send the output to display class
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 8 provide a facility to return a std::vector containing all the name-value attribute pairs attached to that element";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Input is Pointer to Element: " << tag << "\n";
std::vector<std::shared_ptr<AbstractXmlElement>> vectorSharedPtr;
vectorSharedPtr = doc.findById(tag).select();
if (vectorSharedPtr.size() > 0)
dp.displayToConsole(doc.getAttributePairVector(vectorSharedPtr[0]), tag);
else
std::cout <<"\n"<< "Tag: "<<tag<<" is not found in XML";
}
示例10: demonstrateAddRoot
void Executive::demonstrateAddRoot(Display dp, XmlProcessing::XmlDocument &doc,const std::string root)
{
//demonstartes add Root requirement
bool displayFlag = false;
std::cout << "\n""\n""\n" << std::string(150, '=');
std::cout << "\n" << "Demonstrating Requirement 7 by providing the ability to add a root element to an empty document tree";
std::cout << "\n" << std::string(150, '=');
std::cout << "\n" << "Query is:: Add Tagged Element: '" + root + "'id the root is empty." << "\n";
displayFlag = doc.addRoot(root);
if (displayFlag)
{
dp.displayToConsole(doc.getRoot(), displayFlag);
dp.writeToRootXML(doc.getRoot(), displayFlag);
}
else
{
std::cout << "\n""\n" << "Cannot Form New Root because Childrens are already Present" << "\n";
}
}