//------------------------------------------------------------------------------ const std::string& Array::GetGeneratingString(Gmat::WriteMode mode, const std::string &prefix, const std::string &useName) { #ifdef DEBUG_GEN_STRING MessageInterface::ShowMessage("Array::GetGeneratingString() entered\n"); #endif std::stringstream data; bool writeGmatKeyword = GmatGlobal::Instance()->IsWritingGmatKeyword(); // Crank up data precision so we don't lose anything data.precision(GetDataPrecision()); std::string preface = "", nomme; if ((mode == Gmat::SCRIPTING) || (mode == Gmat::OWNED_OBJECT) || (mode == Gmat::SHOW_SCRIPT)) inMatlabMode = false; if (mode == Gmat::MATLAB_STRUCT) inMatlabMode = true; if (useName != "") nomme = useName; else nomme = instanceName; if ((mode == Gmat::SCRIPTING) || (mode == Gmat::SHOW_SCRIPT)) { std::string tname = typeName; // Add comment line (loj: 03/27/07) if (GetCommentLine() != "") data << GetCommentLine(); data << "Create " << tname << " " << nomme << "[" << mNumRows << "," << mNumCols << "];\n"; // We now write out GMAT prefix on option from the startup file (see GMT-3233) if (writeGmatKeyword) preface = "GMAT "; else preface = ""; } nomme += "."; if (mode == Gmat::OWNED_OBJECT) { preface = prefix; nomme = ""; } preface += nomme; WriteParameters(mode, preface, data); generatingString = data.str(); #ifdef DEBUG_GEN_STRING MessageInterface::ShowMessage ("Array::GetGeneratingString() return\n%s\n", generatingString.c_str()); #endif return generatingString; }
//------------------------------------------------------------------------------ const wxString& BeginScript::GetGeneratingString(Gmat::WriteMode mode, const wxString &prefix, const wxString &useName) { //Note: This method is called only once from the ScriptInterpreter::WriteScript() // So all nested ScriptEvent generating string should be handled here wxString gen; wxString indent; wxString commentLine = GetCommentLine(); wxString inlineComment = GetInlineComment(); wxString beginPrefix = prefix; if (mode != Gmat::GUI_EDITOR) { if (mode == Gmat::NO_COMMENTS) { gen << prefix << wxT("BeginScript") << wxT("\n"); } else { IndentComment(gen, commentLine, prefix); gen << prefix << wxT("BeginScript"); if (inlineComment != wxT("")) gen << inlineComment << wxT("\n"); else gen << wxT("\n"); } } #if DBGLVL_GEN_STRING MessageInterface::ShowMessage (wxT("BeginScript::GetGeneratingString() this=(%p)%s, mode=%d, prefix='%s', ") wxT("useName='%s'\n"), this, this->GetTypeName().c_str(), mode, prefix.c_str(), useName.c_str()); #endif if (mode == Gmat::GUI_EDITOR) indent = wxT(""); else indent = wxT(" "); GmatCommand *current = next; while (current != NULL) { #if DBGLVL_GEN_STRING > 1 MessageInterface::ShowMessage (wxT("BeginScript::GetGeneratingString() current=(%p)%s\n"), current, current->GetTypeName().c_str()); #endif if (current->GetTypeName() != wxT("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); } current = NULL; } } generatingString = gen; #if DBGLVL_GEN_STRING MessageInterface::ShowMessage (wxT("BeginScript::GetGeneratingString() returnning generatingString\n")); MessageInterface::ShowMessage(wxT("<<<\n%s>>>\n\n"), generatingString.c_str()); #endif return generatingString; }
//------------------------------------------------------------------------------ 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; }