OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Texts::TextGenerator Class Reference

#include <TextGenerator.hh>

Inheritance diagram for Texts::TextGenerator:
Inheritance graph
Collaboration diagram for Texts::TextGenerator:
Collaboration graph

Public Member Functions

 TextGenerator ()
 
virtual ~TextGenerator ()
 
virtual boost::format text (int textId)
 
virtual void addText (int textId, const std::string &templateString)
 
virtual void replaceText (int textId, const std::string &newString)
 

Private Types

typedef std::map< int, conststd::string * >::value_type ValType
 value_type for map.
 
typedef std::map< int, conststd::string * >::iterator MapIter
 Iterator for map.
 

Private Member Functions

 TextGenerator (const TextGenerator &)
 Copying not allowed.
 
TextGeneratoroperator= (const TextGenerator &)
 Assignment not allowed.
 

Private Attributes

std::map< int, const std::string * > dataBase_
 Database that contains all template strings.
 

Detailed Description

The class that holds template strings and formats them.

Template strings are added with addText function by giving the text id and the template string. Formatted string are achieved by calling text() with text id and parameters. For example text(TXT_HELLO_WORLD, "all") returns "Hello all world".

Definition at line 79 of file TextGenerator.hh.

Member Typedef Documentation

◆ MapIter

typedef std::map<int,conststd::string*>::iterator Texts::TextGenerator::MapIter
private

Iterator for map.

Definition at line 93 of file TextGenerator.hh.

◆ ValType

typedef std::map<int,conststd::string*>::value_type Texts::TextGenerator::ValType
private

value_type for map.

Definition at line 91 of file TextGenerator.hh.

Constructor & Destructor Documentation

◆ TextGenerator() [1/2]

Texts::TextGenerator::TextGenerator ( )

Constructor.

Definition at line 55 of file TextGenerator.cc.

55 {
56 addText(Texts::TXT_HELLO_WORLD, "Hello %s world!");
57 addText(Texts::TXT_FILE_NOT_FOUND, "File not found.");
58 addText(Texts::TXT_FILE_X_NOT_FOUND, "File %s not found.");
59 addText(Texts::TXT_FILE_NOT_READABLE, "File not readable.");
60 addText(Texts::TXT_ILLEGAL_INPUT_FILE, "Illegal input file.");
61 addText(Texts::TXT_NO_FILENAME_DEFINED, "No filename defined.");
62 addText(
64 "Only one filename expected.");
65 addText(Texts::TXT_NO_SUCH_SETTING, "No such setting.");
66 addText(Texts::TXT_UNKNOWN_COMMAND, "Unknown command.");
67 addText(Texts::TXT_UNKNOWN_SUBCOMMAND, "Unknown subcommand.");
68 addText(Texts::TXT_ILLEGAL_ARGUMENT, "Illegal argument.");
69 addText(Texts::TXT_ILLEGAL_ARGUMENTS, "Illegal arguments.");
70
71}
virtual void addText(int textId, const std::string &templateString)
@ TXT_HELLO_WORLD
For testing. Do not remove.
@ TXT_ONLY_ONE_FILENAME_EXPECTED
@ TXT_ILLEGAL_INPUT_FILE
@ TXT_ILLEGAL_ARGUMENT
@ TXT_NO_SUCH_SETTING
@ TXT_FILE_X_NOT_FOUND
@ TXT_NO_FILENAME_DEFINED
@ TXT_FILE_NOT_READABLE
@ TXT_UNKNOWN_COMMAND
@ TXT_FILE_NOT_FOUND
@ TXT_UNKNOWN_SUBCOMMAND
@ TXT_ILLEGAL_ARGUMENTS

References addText(), Texts::TXT_FILE_NOT_FOUND, Texts::TXT_FILE_NOT_READABLE, Texts::TXT_FILE_X_NOT_FOUND, Texts::TXT_HELLO_WORLD, Texts::TXT_ILLEGAL_ARGUMENT, Texts::TXT_ILLEGAL_ARGUMENTS, Texts::TXT_ILLEGAL_INPUT_FILE, Texts::TXT_NO_FILENAME_DEFINED, Texts::TXT_NO_SUCH_SETTING, Texts::TXT_ONLY_ONE_FILENAME_EXPECTED, Texts::TXT_UNKNOWN_COMMAND, and Texts::TXT_UNKNOWN_SUBCOMMAND.

Here is the call graph for this function:

◆ ~TextGenerator()

Texts::TextGenerator::~TextGenerator ( )
virtual

Destructor.

Frees the allocated memory.

Definition at line 79 of file TextGenerator.cc.

79 {
80 for (MapIter mi = dataBase_.begin(); mi != dataBase_.end(); mi++) {
81 delete (*mi).second;
82 }
83}
std::map< int, const std::string * > dataBase_
Database that contains all template strings.
std::map< int, conststd::string * >::iterator MapIter
Iterator for map.

◆ TextGenerator() [2/2]

Texts::TextGenerator::TextGenerator ( const TextGenerator )
private

Copying not allowed.

Member Function Documentation

◆ addText()

void Texts::TextGenerator::addText ( int  textId,
const std::string &  templateString 
)
virtual

Records a new template string that can be used to generate text messages.

The template string is first copied to the dynamically allocated string, just to ensure that it will be not destroyed before TextGenerator.

Parameters
textIdNumeric code that identifies the template string.
templateStringTemplate string to be recorded.

Definition at line 118 of file TextGenerator.cc.

118 {
119 string* toBeAdded = new string(templateString);
120 dataBase_.insert(ValType(textId, toBeAdded));
121}
std::map< int, conststd::string * >::value_type ValType
value_type for map.

Referenced by ADFSerializerTextGenerator::ADFSerializerTextGenerator(), BEMGeneratorCLITextGenerator::BEMGeneratorCLITextGenerator(), BEMTextGenerator::BEMTextGenerator(), GUITextGenerator::GUITextGenerator(), MachineTestReportTextGenerator::MachineTestReportTextGenerator(), MOMTextGenerator::MOMTextGenerator(), OSEdTextGenerator::OSEdTextGenerator(), PIGCLITextGenerator::PIGCLITextGenerator(), PIGTextGenerator::PIGTextGenerator(), ProDeTextGenerator::ProDeTextGenerator(), SimulatorTextGenerator::SimulatorTextGenerator(), and TextGenerator().

◆ operator=()

TextGenerator & Texts::TextGenerator::operator= ( const TextGenerator )
private

Assignment not allowed.

◆ replaceText()

void Texts::TextGenerator::replaceText ( int  textId,
const std::string &  newString 
)
virtual

Replaces existing text with a new one.

Parameters
textIDID of the text to be replaced
newStringnew string to be set
Exceptions
KeyNotFoundThrown if a text of given ID couldn't be found.

Definition at line 132 of file TextGenerator.cc.

132 {
133 if (!MapTools::containsKey(dataBase_, textId)) {
134 string message("Requested message (code ");
135 message += Conversion::toString(textId) + ") does not exist.";
136 throw KeyNotFound(__FILE__, __LINE__, __FUNCTION__, message);
137 }
138
139 delete dataBase_[textId];
140 string* toBeAdded = new string(newString);
141 dataBase_[textId] = toBeAdded;
142}
static std::string toString(const T &source)
static bool containsKey(const MapType &aMap, const KeyType &aKey)

References MapTools::containsKey(), and Conversion::toString().

Referenced by SimulatorTextGenerator::generateCompiledSimTexts().

Here is the call graph for this function:

◆ text()

format Texts::TextGenerator::text ( int  textId)
virtual

Returns a format object that contains the template string.

Parameters
textIdNumeric code that identifies the template string.
Returns
format object that contains the template string.
Exceptions
KeyNotFoundIf textId doesn't identify any template string.

Definition at line 94 of file TextGenerator.cc.

94 {
95 if (!MapTools::containsKey(dataBase_, textId)) {
96 string method = "TextGenerator::text()";
97 string message("Requested message (code ");
98 message += Conversion::toString(textId) + ") does not exist.";
99 throw KeyNotFound(__FILE__, __LINE__, method, message);
100 }
101
102 MapIter mt = dataBase_.find(textId);
103 const string& templateString = *((*mt).second);
104
105 return format(templateString);
106}

References MapTools::containsKey(), and Conversion::toString().

Referenced by CodeCompressorPlugin::addBitsForGuardField(), CodeCompressorPlugin::addBitsForICField(), CodeCompressorPlugin::addBitsForImmediateSlot(), CodeCompressorPlugin::addBitsForMoveSlot(), TTAMachine::AddressSpace::AddressSpace(), TTAMachine::Bus::adjustSegmentChain(), MachineStateBuilder::bindPortsToOperands(), TTAMachine::Bridge::Bridge(), MachineTestReporter::bridgingError(), CompiledSimSettingCommand::CompiledSimSettingCommand(), TTAMachine::Component::Component(), OSEdAddModuleCmd::Do(), OSEdBuildAllCmd::Do(), OSEdBuildCmd::Do(), OSEdModifyBehaviorCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveModuleCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdUserManualCmd::Do(), AddBridgeCmd::Do(), AddGCUCmd::Do(), PasteComponentCmd::Do(), DropDownMenu::DropDownMenu(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeNOP(), CodeCompressorPlugin::encodeRFTerminal(), ConfCommand::execute(), HelpCommand::execute(), InfoProgramCommand::execute(), MachCommand::execute(), ProgCommand::execute(), ProDeBridgeEditPolicy::getCommand(), ProDeBusEditPolicy::getCommand(), ProDeFUEditPolicy::getCommand(), ProDeGCUEditPolicy::getCommand(), ProDeIUEditPolicy::getCommand(), ProDePortEditPolicy::getCommand(), ProDeRFEditPolicy::getCommand(), ProDeSegmentEditPolicy::getCommand(), ProDeSocketEditPolicy::getCommand(), BPCommand::helpText(), CommandsCommand::helpText(), ConditionCommand::helpText(), ConfCommand::helpText(), DeleteBPCommand::helpText(), DisableBPCommand::helpText(), DisassembleCommand::helpText(), EnableBPCommand::helpText(), HelpCommand::helpText(), IgnoreCommand::helpText(), InfoCommand::helpText(), KillCommand::helpText(), MachCommand::helpText(), MemDumpCommand::helpText(), MemWriteCommand::helpText(), NextiCommand::helpText(), ProgCommand::helpText(), QuitCommand::helpText(), ResumeCommand::helpText(), RunCommand::helpText(), SettingCommand::helpText(), StepiCommand::helpText(), TBPCommand::helpText(), UntilCommand::helpText(), WatchCommand::helpText(), TTAMachine::HWOperation::HWOperation(), TTAMachine::ImmediateSlot::ImmediateSlot(), ADFSerializer::immediateUnitToMachine(), SimulatorFrontend::initializeDataMemories(), OSEdInfoView::insertOperationPropertyColumns(), TTAMachine::InstructionTemplate::InstructionTemplate(), CodeCompressorPlugin::instructionTemplate(), ADFSerializer::instructionTemplateToMachine(), SimulatorFrontend::loadMachine(), SimulatorFrontend::loadProcessorConfiguration(), SimulatorFrontend::loadProgram(), TTAMachine::Bridge::loadState(), TTAMachine::ExecutionPipeline::loadState(), TTAMachine::FunctionUnit::loadState(), TTAMachine::PortGuard::loadState(), TTAMachine::RegisterGuard::loadState(), TTAMachine::HWOperation::loadState(), TTAMachine::InstructionTemplate::loadState(), TTAMachine::Component::loadState(), TTAMachine::Port::loadState(), TTAMachine::Socket::loadState(), TTAMachine::Bus::loadStateWithoutReferences(), TTAMachine::FUPort::loadStateWithoutReferences(), main(), OSEdInfoView::moduleView(), OperationPropertyDialog::onAddAffectedBy(), OperationPropertyDialog::onAddAffects(), BusDialog::onAddFUGuard(), OperationDialog::onAddOperand(), OTAFormatListDialog::onAddOTAFormat(), OperationDialog::onAddResource(), BusDialog::onAddRFGuard(), BusDialog::onAddSegment(), ImmediateSlotDialog::onAddSlot(), TemplateListDialog::onAddSlot(), TemplateListDialog::onAddTemplate(), AddressSpacesDialog::onASRightClick(), OSEdMainFrame::onCommandEvent(), OperationDialog::onDeleteOperand(), OperationDialog::onDeleteResource(), OSEdInfoView::onDropDownMenu(), OSEdTreeView::onDropDownMenu(), BusDialog::onFUGuardRightClick(), OSEd::OnInit(), OSEdTreeView::onItemSelected(), BridgeDialog::onOK(), BusDialog::onOK(), SocketDialog::onOK(), AddModuleDialog::onOk(), AddressSpaceDialog::onOK(), FUDialog::onOK(), FUGuardDialog::onOK(), FUPortDialog::onOK(), GCUDialog::onOK(), IUDialog::onOK(), IUPortDialog::onOK(), OperationDialog::onOK(), RFDialog::onOK(), RFGuardDialog::onOK(), RFPortDialog::onOK(), SRPortDialog::onOK(), OperationPropertyDialog::onOpen(), ResultDialog::onOpen(), OperationDialog::onOperandLClick(), FUDialog::onOperationRightClick(), GCUDialog::onOperationRightClick(), FUDialog::onPortRightClick(), GCUDialog::onPortRightClick(), RFDialog::onPortRightClick(), OperationDialog::onResourceLClick(), RFGuardDialog::onRFChoice(), BusDialog::onRFGuardRightClick(), OSEdOptionsDialog::onSave(), BusDialog::onSegmentRightClick(), OSEdInfoView::onSelection(), BusDialog::onUnconditionalGuard(), MDFDocument::openADF(), OSEdInfoView::operationPropertyView(), TTAMachine::OperationTriggeredFormat::OperationTriggeredFormat(), OSEdInfoView::operationView(), OSEdMainFrame::OSEdMainFrame(), OSEdInfoView::pathView(), TTAMachine::Port::Port(), TTAMachine::PortGuard::PortGuard(), SimulatorCmdLineOptions::printHelp(), SimControlLanguageCommand::printStopReasons(), PIGCmdLineOptions::printUsage(), BEMGeneratorCmdLineOptions::printVersion(), PIGCmdLineOptions::printVersion(), SimProgramBuilder::processBidirTerminal(), TTAMachine::RegisterGuard::RegisterGuard(), TTAMachine::RegisterGuard::RegisterGuard(), TTAMachine::Socket::setDirection(), TTAMachine::ControlUnit::setGlobalGuardLatency(), SourceField::setImmediateEncoding(), WidgetTools::setLabel(), GCUDialog::setLabels(), TTAMachine::HWOperation::setName(), TTAMachine::Component::setName(), AddModuleDialog::setTexts(), InputOperandDialog::setTexts(), MemoryDialog::setTexts(), OperationDAGDialog::setTexts(), OperationPropertyDialog::setTexts(), OSEdAboutDialog::setTexts(), OSEdOptionsDialog::setTexts(), OutputOperandDialog::setTexts(), SimulateDialog::setTexts(), SimulationInfoDialog::setTexts(), AboutDialog::setTexts(), AddressSpaceDialog::setTexts(), AddressSpacesDialog::setTexts(), BridgeDialog::setTexts(), BusDialog::setTexts(), CallExplorerPluginWindow::setTexts(), EditParameterDialog::setTexts(), FUDialog::setTexts(), FUGuardDialog::setTexts(), FUPortDialog::setTexts(), ImmediateSlotDialog::setTexts(), IUDialog::setTexts(), IUPortDialog::setTexts(), OperationDialog::setTexts(), OTAFormatListDialog::setTexts(), RFDialog::setTexts(), RFGuardDialog::setTexts(), RFPortDialog::setTexts(), SocketDialog::setTexts(), SRPortDialog::setTexts(), TemplateListDialog::setTexts(), TemplateSlotDialog::setTexts(), SettingCommand::SettingCommand(), SimulateDialog::showOrHideRegisters(), SimulationInfoDialog::SimulationInfoDialog(), MachineTestReporter::socketDirectionSettingError(), MachineTestReporter::socketPortConnectionError(), MachineTestReporter::socketSegmentConnectionError(), RFGuardDialog::TransferDataToWindow(), TTAMachine::UnconditionalGuard::UnconditionalGuard(), OperationPropertyDialog::updateOperation(), OperationDialog::warnOnResourcesWithoutUsages(), and OSEdInfoView::writeStaticPropertiesOfOperation().

Here is the call graph for this function:

Member Data Documentation

◆ dataBase_

std::map<int, const std::string*> Texts::TextGenerator::dataBase_
private

Database that contains all template strings.

Definition at line 101 of file TextGenerator.hh.


The documentation for this class was generated from the following files: