1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ArgvKeeper.hxx"
25 std::recursive_mutex mutex; //!< mutex to protect access to static data
26 std::vector<std::string> argv_list; //!< cmd line arguments
27 bool isInitialized = false; //!< \c true if cmd line arguments were initialized
30 //! \brief Store cmd line arguments
31 void SetArgcArgv(int argc, char* argv[])
33 std::vector<std::string> tmp_list;
34 for (int i=0; i < argc; ++i)
35 tmp_list.push_back(std::string(argv[i]));
36 SetArgcArgv(tmp_list);
39 //! \overload void SetArgcArgv(int argc, char* argv[])
40 void SetArgcArgv(const std::vector<std::string>& argv)
42 std::lock_guard<std::recursive_mutex> g(mutex);
43 if (!isInitialized && !argv.empty())
46 for (const std::string& value: argv) {
47 argv_list.push_back(value);
52 //! \brief Get cmd line arguments
53 std::vector<std::string> GetArgcArgv()
55 std::lock_guard<std::recursive_mutex> g(mutex);
59 //! \brief Check if cmd line arguments were initialized
61 //! In debug mode returns \c true if SetArgcArgv() was called or \c false otherwise.
62 //! In release mode always returns \c true.
63 bool ArgcArgvInitialized()