bool ClassDiagram::loadDiagram(File &file) { NameValueFile nameValFile; bool success = nameValFile.readFile(file); if(success) { CompoundValue names; names.parseString(nameValFile.getValue("Names")); CompoundValue xPositions; xPositions.parseString(nameValFile.getValue("XPositions")); CompoundValue yPositions; yPositions.parseString(nameValFile.getValue("YPositions")); std::vector<ClassNode> &nodes = getNodes(); for(size_t i=0; i<names.size(); i++) { OovString name = names[i]; if(i == 0) { // The node at index zero is the graph key, and is not stored in // the graph with a name or type. // The node at index one is the first class, which is typically the // same as the drawing name. eDiagramStorageTypes drawingType; OovString drawingName; DiagramStorage::getDrawingHeader(nameValFile, drawingType, drawingName); // This adds the key automatically as item index zero. // Call this function to set the last selected class name for the journal. clearGraphAndAddClass(drawingName, ClassGraph::AN_All, ClassDiagram::DEPTH_SINGLE_CLASS, false); int x=0; int y=0; xPositions[i].getInt(0, INT_MAX, x); yPositions[i].getInt(0, INT_MAX, y); nodes[0].setPosition(GraphPoint(x, y)); } else { // This will not add duplicates, so if the name is different // from the drawingName, it will be added. addClass(name, ClassGraph::AN_All, ClassDiagram::DEPTH_SINGLE_CLASS, false); } auto nodeIter = std::find_if(nodes.begin(), nodes.end(), [&name](ClassNode &node) { return(node.getType() && name == node.getType()->getName()); }); if(nodeIter != nodes.end()) { int x=0; int y=0; xPositions[i].getInt(0, INT_MAX, x); yPositions[i].getInt(0, INT_MAX, y); nodeIter->setPosition(GraphPoint(x, y)); } } } return success; }
void TextViewOption::screenToOption(NameValueFile &file) const { GtkTextView *view = GTK_TEXT_VIEW(Builder::getBuilder()->getWidget(mWidgetName)); std::string str = Gui::getText(view); CompoundValue cppArgs; cppArgs.parseString(str, '\n'); std::string newCppArgsStr = cppArgs.getAsString(); file.setNameValue(mOptionName, newCppArgsStr); }
void TextViewOption::optionToScreen(NameValueFile const &file) const { CompoundValue cppArgs; cppArgs.parseString(file.getValue(mOptionName)); GtkTextView *view = GTK_TEXT_VIEW(Builder::getBuilder()->getWidget(mWidgetName)); Gui::clear(view); std::string str = cppArgs.getAsString('\n'); Gui::appendText(view, str); }
OovStatusReturn ClassDiagram::saveDiagram(File &file) { OovStatus status(true, SC_File); NameValueFile nameValFile; CompoundValue names; CompoundValue xPositions; CompoundValue yPositions; OovString drawingName; for(auto const &node : mClassGraph.getNodes()) { if(node.getType()) { if(drawingName.length() == 0) { drawingName = node.getType()->getName(); } names.addArg(node.getType()->getName()); } else { names.addArg("Oov-Key"); } OovString num; num.appendInt(node.getPosition().x); xPositions.addArg(num); num.clear(); num.appendInt(node.getPosition().y); yPositions.addArg(num); } if(drawingName.length() > 0) { DiagramStorage::setDrawingHeader(nameValFile, DST_Class, drawingName); nameValFile.setNameValue("Names", names.getAsString()); nameValFile.setNameValue("XPositions", xPositions.getAsString()); nameValFile.setNameValue("YPositions", yPositions.getAsString()); status = nameValFile.writeFile(file); } return status; }
static void setBuildConfigurationPaths(NameValueFile &file, OovStringRef const buildConfig, OovStringRef const extraArgs, bool useclang) { std::string optStr = makeBuildConfigArgName(OptExtraBuildArgs, buildConfig); file.setNameValue(optStr, extraArgs); if(std::string(buildConfig).compare(BuildConfigAnalysis) == 0) { useclang = true; } // Assume the archiver is installed and on path. // llvm-ar gives link error. // setNameValue(makeExeFilename("llvm-ar")); optStr = makeBuildConfigArgName(OptToolLibPath, buildConfig); file.setNameValue(optStr, FilePathMakeExeFilename("ar")); // llvm-nm gives bad file error on Windows, and has no output on Linux. // mPathObjSymbol = "makeExeFilename(llvm-nm)"; optStr = makeBuildConfigArgName(OptToolObjSymbolPath, buildConfig); file.setNameValue(optStr, FilePathMakeExeFilename("nm")); std::string compiler; if(useclang) compiler = FilePathMakeExeFilename("clang++"); else compiler = FilePathMakeExeFilename("g++"); optStr = makeBuildConfigArgName(OptToolCompilePath, buildConfig); file.setNameValue(optStr, compiler); optStr = makeBuildConfigArgName(OptToolJavaCompilePath, buildConfig); file.setNameValue(optStr, "javac"); optStr = makeBuildConfigArgName(OptToolJavaJarToolPath, buildConfig); file.setNameValue(optStr, "jar"); }
void CheckOption::screenToOption(NameValueFile &file) const { bool active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( Builder::getBuilder()->getWidget(mWidgetName))); file.setNameValueBool(mOptionName, active); }
void CheckOption::optionToScreen(NameValueFile const &file) const { bool active = file.getValueBool(mOptionName); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( Builder::getBuilder()->getWidget(mWidgetName)), active); }
void EntryOption::screenToOption(NameValueFile &file) const { GtkEntry *editPath = GTK_ENTRY(Builder::getBuilder()->getWidget(mWidgetName)); file.setNameValue(mOptionName, Gui::getText(editPath)); }
void EntryOption::optionToScreen(NameValueFile const &file) const { GtkEntry *entry = GTK_ENTRY(Builder::getBuilder()->getWidget(mWidgetName)); Gui::setText(entry, file.getValue(mOptionName)); }