From 1dc20ee0d6c723c7895d41136f6ab132416608f8 Mon Sep 17 00:00:00 2001 From: bofdahof <172177156+bofdahof@users.noreply.github.com> Date: Sat, 8 Mar 2025 13:18:06 +1000 Subject: [PATCH] remove using namespace std --- src/App/Application.cpp | 112 ++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 3412f7dbc4..2c956013ae 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -172,7 +172,7 @@ FC_LOG_LEVEL_INIT("App", true, true) using namespace App; //using namespace Base; -using namespace std; +//using namespace std; //using namespace boost; using namespace boost::program_options; using Base::FileInfo; @@ -1639,7 +1639,7 @@ void Application::slotBeforeRecompute(const Document& doc) this->signalBeforeRecomputeDocument(doc); } -void Application::slotOpenTransaction(const Document &doc, string name) +void Application::slotOpenTransaction(const Document &doc, std::string name) { this->signalOpenTransaction(doc, std::move(name)); } @@ -2215,7 +2215,7 @@ void Application::initTypes() namespace { -void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& vm) +void parseProgramOptions(int ac, char ** av, const std::string& exe, variables_map& vm) { // Declare a group of options that will be // allowed only on the command line @@ -2225,10 +2225,10 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v ("verbose", "Prints verbose version string") ("help,h", "Prints help message") ("console,c", "Starts in console mode") - ("response-file", value(),"Can be specified with '@name', too") + ("response-file", value(),"Can be specified with '@name', too") ("dump-config", "Dumps configuration") - ("get-config", value(), "Prints the value of the requested configuration key") - ("set-config", value< vector >()->multitoken(), "Sets the value of a configuration key") + ("get-config", value(), "Prints the value of the requested configuration key") + ("set-config", value< std::vector >()->multitoken(), "Sets the value of a configuration key") ("keep-deprecated-paths", "If set then config files are kept on the old location") ; @@ -2240,18 +2240,18 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v boost::program_options::options_description config("Configuration"); config.add_options() ("write-log,l", descr.str().c_str()) - ("log-file", value(), "Unlike --write-log this allows logging to an arbitrary file") - ("user-cfg,u", value(),"User config file to load/save user settings") - ("system-cfg,s", value(),"System config file to load/save system settings") - ("run-test,t", value()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests.") - ("run-open,r", value()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests. Keeps UI open after test(s) complete.") - ("module-path,M", value< vector >()->composing(),"Additional module paths") - ("macro-path,E", value< vector >()->composing(),"Additional macro paths") - ("python-path,P", value< vector >()->composing(),"Additional python paths") - ("disable-addon", value< vector >()->composing(),"Disable a given addon.") + ("log-file", value(), "Unlike --write-log this allows logging to an arbitrary file") + ("user-cfg,u", value(),"User config file to load/save user settings") + ("system-cfg,s", value(),"System config file to load/save system settings") + ("run-test,t", value()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests.") + ("run-open,r", value()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests. Keeps UI open after test(s) complete.") + ("module-path,M", value< std::vector >()->composing(),"Additional module paths") + ("macro-path,E", value< std::vector >()->composing(),"Additional macro paths") + ("python-path,P", value< std::vector >()->composing(),"Additional python paths") + ("disable-addon", value< std::vector >()->composing(),"Disable a given addon.") ("single-instance", "Allow to run a single instance of the application") ("safe-mode", "Force enable safe mode") - ("pass", value< vector >()->multitoken(), "Ignores the following arguments and pass them through to be used by a script") + ("pass", value< std::vector >()->multitoken(), "Ignores the following arguments and pass them through to be used by a script") ; @@ -2259,33 +2259,33 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v // in the config file, but will not be shown to the user. boost::program_options::options_description hidden("Hidden options"); hidden.add_options() - ("input-file", boost::program_options::value< vector >(), "input file") - ("output", boost::program_options::value(),"output file") + ("input-file", boost::program_options::value< std::vector >(), "input file") + ("output", boost::program_options::value(),"output file") ("hidden", "don't show the main window") // this are to ignore for the window system (QApplication) - ("style", boost::program_options::value< string >(), "set the application GUI style") - ("stylesheet", boost::program_options::value< string >(), "set the application stylesheet") - ("session", boost::program_options::value< string >(), "restore the application from an earlier session") + ("style", boost::program_options::value< std::string >(), "set the application GUI style") + ("stylesheet", boost::program_options::value< std::string >(), "set the application stylesheet") + ("session", boost::program_options::value< std::string >(), "restore the application from an earlier session") ("reverse", "set the application's layout direction from right to left") ("widgetcount", "print debug messages about widgets") - ("graphicssystem", boost::program_options::value< string >(), "backend to be used for on-screen widgets and pixmaps") - ("display", boost::program_options::value< string >(), "set the X-Server") - ("geometry ", boost::program_options::value< string >(), "set the X-Window geometry") - ("font", boost::program_options::value< string >(), "set the X-Window font") - ("fn", boost::program_options::value< string >(), "set the X-Window font") - ("background", boost::program_options::value< string >(), "set the X-Window background color") - ("bg", boost::program_options::value< string >(), "set the X-Window background color") - ("foreground", boost::program_options::value< string >(), "set the X-Window foreground color") - ("fg", boost::program_options::value< string >(), "set the X-Window foreground color") - ("button", boost::program_options::value< string >(), "set the X-Window button color") - ("btn", boost::program_options::value< string >(), "set the X-Window button color") - ("name", boost::program_options::value< string >(), "set the X-Window name") - ("title", boost::program_options::value< string >(), "set the X-Window title") - ("visual", boost::program_options::value< string >(), "set the X-Window to color scheme") + ("graphicssystem", boost::program_options::value< std::string >(), "backend to be used for on-screen widgets and pixmaps") + ("display", boost::program_options::value< std::string >(), "set the X-Server") + ("geometry ", boost::program_options::value< std::string >(), "set the X-Window geometry") + ("font", boost::program_options::value< std::string >(), "set the X-Window font") + ("fn", boost::program_options::value< std::string >(), "set the X-Window font") + ("background", boost::program_options::value< std::string >(), "set the X-Window background color") + ("bg", boost::program_options::value< std::string >(), "set the X-Window background color") + ("foreground", boost::program_options::value< std::string >(), "set the X-Window foreground color") + ("fg", boost::program_options::value< std::string >(), "set the X-Window foreground color") + ("button", boost::program_options::value< std::string >(), "set the X-Window button color") + ("btn", boost::program_options::value< std::string >(), "set the X-Window button color") + ("name", boost::program_options::value< std::string >(), "set the X-Window name") + ("title", boost::program_options::value< std::string >(), "set the X-Window title") + ("visual", boost::program_options::value< std::string >(), "set the X-Window to color scheme") ("ncols", boost::program_options::value< int >(), "set the X-Window to color scheme") ("cmap", "set the X-Window to color scheme") #if defined(FC_OS_MACOSX) - ("psn", boost::program_options::value< string >(), "process serial number") + ("psn", boost::program_options::value< std::string >(), "process serial number") #endif ; @@ -2361,21 +2361,21 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v if (vm.count("response-file")) { // Load the file and tokenize it - std::ifstream ifs(vm["response-file"].as().c_str()); + std::ifstream ifs(vm["response-file"].as().c_str()); if (!ifs) { Base::Console().Error("Could no open the response file\n"); std::stringstream str; str << "Could no open the response file: '" - << vm["response-file"].as() << "'" << '\n'; + << vm["response-file"].as() << "'" << '\n'; throw Base::UnknownProgramOption(str.str()); } // Read the whole file into a string - stringstream ss; + std::stringstream ss; ss << ifs.rdbuf(); // Split the file content boost::char_separator sep(" \n\r"); boost::tokenizer > tok(ss.str(), sep); - vector args2; + std::vector args2; copy(tok.begin(), tok.end(), back_inserter(args2)); // Parse the file and store the options store( boost::program_options::command_line_parser(args2). @@ -2411,8 +2411,8 @@ void processProgramOptions(const variables_map& vm, std::map >(); - string temp; + auto Mods = vm["module-path"].as< std::vector >(); + std::string temp; for (const auto & It : Mods) temp += It + ";"; temp.erase(temp.end()-1); @@ -2420,8 +2420,8 @@ void processProgramOptions(const variables_map& vm, std::map Macros = vm["macro-path"].as< vector >(); - string temp; + std::vector Macros = vm["macro-path"].as< std::vector >(); + std::string temp; for (const auto & It : Macros) temp += It + ";"; temp.erase(temp.end()-1); @@ -2429,14 +2429,14 @@ void processProgramOptions(const variables_map& vm, std::map >(); + auto Paths = vm["python-path"].as< std::vector >(); for (const auto & It : Paths) Base::Interpreter().addPythonPath(It.c_str()); } if (vm.count("disable-addon")) { - auto Addons = vm["disable-addon"].as< vector >(); - string temp; + auto Addons = vm["disable-addon"].as< std::vector >(); + std::string temp; for (const auto & It : Addons) { temp += It + ";"; } @@ -2445,7 +2445,7 @@ void processProgramOptions(const variables_map& vm, std::map >()); + auto files(vm["input-file"].as< std::vector >()); int OpenFileCount=0; for (const auto & It : files) { @@ -2460,7 +2460,7 @@ void processProgramOptions(const variables_map& vm, std::map(); + mConfig["SaveFile"] = vm["output"].as(); } if (vm.count("hidden")) { @@ -2474,19 +2474,19 @@ void processProgramOptions(const variables_map& vm, std::map(); + mConfig["LoggingFileName"] = vm["log-file"].as(); } if (vm.count("user-cfg")) { - mConfig["UserParameter"] = vm["user-cfg"].as(); + mConfig["UserParameter"] = vm["user-cfg"].as(); } if (vm.count("system-cfg")) { - mConfig["SystemParameter"] = vm["system-cfg"].as(); + mConfig["SystemParameter"] = vm["system-cfg"].as(); } if (vm.count("run-test") || vm.count("run-open")) { - string testCase = vm.count("run-open") ? vm["run-open"].as() : vm["run-test"].as(); + std::string testCase = vm.count("run-open") ? vm["run-open"].as() : vm["run-test"].as(); if ( "0" == testCase) { testCase = "TestApp.All"; @@ -2513,7 +2513,7 @@ void processProgramOptions(const variables_map& vm, std::map(); + auto configKey = vm["get-config"].as(); std::stringstream str; std::map::iterator pos; pos = mConfig.find(configKey); @@ -3080,9 +3080,9 @@ void Application::LoadParameters() // A helper function to simplify the main part. template -ostream& operator<<(ostream& os, const vector& v) +std::ostream& operator<<(std::ostream& os, const std::vector& v) { - copy(v.begin(), v.end(), ostream_iterator(cout, " ")); + copy(v.begin(), v.end(), std::ostream_iterator(std::cout, " ")); return os; }