//------------------------------------------------------------------------------ // GetGeneratingString //------------------------------------------------------------------------------ const std::string& EndOptimize::GetGeneratingString(Gmat::WriteMode mode, const std::string &prefix, const std::string &useName) { generatingString = prefix + "EndOptimize;"; if (mode == Gmat::NO_COMMENTS) { InsertCommandName(generatingString); return generatingString; } if ((next) && (next->GetTypeName() == "Optimize")) { if (showInlineComment) { // To avoid keep appending, check for empty inline comment if (GetInlineComment() == "") { generatingString += " % For optimizer "; generatingString += next->GetRefObjectName(Gmat::SOLVER); } } } return GmatCommand::GetGeneratingString(mode, prefix, useName); }
//------------------------------------------------------------------------------ const std::string& EndTarget::GetGeneratingString(Gmat::WriteMode mode, const std::string &prefix, const std::string &useName) { if (mode == Gmat::NO_COMMENTS) { generatingString = "EndTarget;"; InsertCommandName(generatingString); return generatingString; } // Build the local string generatingString = prefix + "EndTarget;"; if ((next) && (next->GetTypeName() == "Target")) { // To avoid keep appending, check for empty inline comment if (GetInlineComment() == "") { generatingString += " % For targeter "; generatingString += next->GetRefObjectName(Gmat::SOLVER); } } // Then call the base class method for preface and inline comments // We want preface comment to be indented return GmatCommand::GetGeneratingString(mode, prefix + " ", useName); }
//------------------------------------------------------------------------------ const std::string& BeginScript::GetGeneratingString(Gmat::WriteMode mode, const std::string &prefix, const std::string &useName) { //Note: This method is called only once from the ScriptInterpreter::WriteScript(), // so all nested ScriptEvent generating strings should be handled here. std::stringstream gen; std::string indent; std::string commentLine = GetCommentLine(); std::string inlineComment = GetInlineComment(); std::string beginPrefix = prefix; if (mode != Gmat::GUI_EDITOR) { if (mode == Gmat::NO_COMMENTS) { gen << prefix << "BeginScript" << "\n"; } else { IndentComment(gen, commentLine, prefix); // Insert command name (Fix for GMT-2612, LOJ: 2012.10.22) //gen << prefix << "BeginScript"; std::string tempString = prefix + "BeginScript"; InsertCommandName(tempString); gen << tempString; if (inlineComment != "") gen << inlineComment << "\n"; else gen << "\n"; } } #if DBGLVL_GEN_STRING MessageInterface::ShowMessage ("BeginScript::GetGeneratingString() this=(%p)%s, mode=%d, prefix='%s', " "useName='%s'\n", this, this->GetTypeName().c_str(), mode, prefix.c_str(), useName.c_str()); #endif if (mode == Gmat::GUI_EDITOR) indent = ""; else indent = " "; GmatCommand *current = next; while (current != NULL) { #if DBGLVL_GEN_STRING > 1 MessageInterface::ShowMessage ("BeginScript::GetGeneratingString() current=(%p)%s\n", current, current->GetTypeName().c_str()); #endif if (current->GetTypeName() != "EndScript") { // Indent whole block within Begin/EndScript IndentChildString(gen, current, indent, mode, prefix, useName, false); // Get command after EndScript current = GmatCommandUtil::GetNextCommand(current); if (current == NULL) IndentChildString(gen, current, indent, mode, beginPrefix, useName, true); } else { if (mode != Gmat::GUI_EDITOR) { // Indent whole block within Begin/EndScript IndentChildString(gen, current, indent, mode, beginPrefix, useName, true); } else { std::string comment = current->GetCommentLine(); #if DBGLVL_GEN_STRING MessageInterface::ShowMessage(" EndScript comment = '%s'\n", comment.c_str()); #endif // Only indent inline comment of EndScript (LOJ: 2013.03.27) gen << indent << comment; } current = NULL; } } generatingString = gen.str(); #if DBGLVL_GEN_STRING MessageInterface::ShowMessage ("BeginScript::GetGeneratingString() returnning generatingString\n"); MessageInterface::ShowMessage("<<<\n%s>>>\n\n", generatingString.c_str()); #endif return generatingString; }