diff --git a/src/app.cpp b/src/app.cpp index efd14f22f..ce30f7f8d 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -110,7 +110,7 @@ static TabsBarHandler* tabsHandler = NULL; // Initializes the application loading the modules, setting the // graphics mode, loading the configuration and resources, etc. -App::App() +App::App(int argc, char* argv[]) : m_configModule(NULL) , m_checkArgs(NULL) , m_loggerModule(NULL) @@ -121,8 +121,11 @@ App::App() ASSERT(m_instance == NULL); m_instance = this; + for (int i = 0; i < argc; ++i) + m_args.push_back(argv[i]); + m_configModule = new ConfigModule(); - m_checkArgs = new CheckArgs(); + m_checkArgs = new CheckArgs(m_args); m_loggerModule = new LoggerModule(m_checkArgs->isVerbose()); m_modules = new Modules(); m_isGui = !(m_checkArgs->isConsoleOnly()); @@ -243,7 +246,7 @@ int App::run() case CheckArgs::Option::OpenSprite: { /* load the sprite */ - Sprite* sprite = sprite_load(Vaca::convert_to(option->data()).c_str()); + Sprite* sprite = sprite_load(option->data().c_str()); if (!sprite) { if (!isGui()) console.printf("Error loading file \"%s\"\n", option->data().c_str()); @@ -259,7 +262,7 @@ int App::run() set_sprite_in_more_reliable_editor(context->get_first_sprite()); // Recent file - getRecentFiles()->addRecentFile(Vaca::convert_to(option->data()).c_str()); + getRecentFiles()->addRecentFile(option->data().c_str()); } } break; diff --git a/src/app.h b/src/app.h index bc294912b..3eb19a74b 100644 --- a/src/app.h +++ b/src/app.h @@ -20,6 +20,7 @@ #define APP_H_INCLUDED #include "base/signal.h" +#include "base/string.h" #include "gui/jbase.h" #include @@ -41,11 +42,16 @@ class ToolBox; class App { public: - App(); + App(int argc, char* argv[]); ~App(); static App* instance() { return m_instance; } + // Functions to get the arguments specified in the command line. + int getArgc() const { return m_args.size(); } + const base::string& getArgv(int i) { return m_args[i]; } + const std::vector& getArgs() const { return m_args; } + // Returns true if ASE is running with GUI available. bool isGui() const { return m_isGui; } @@ -75,6 +81,7 @@ private: Modules* m_modules; LegacyModules* m_legacy; bool m_isGui; + std::vector m_args; }; void app_refresh_screen(const Sprite* sprite); diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index fcd410a7d..1128291ef 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -2,6 +2,7 @@ # Copyright (C) 2001-2010 David Capello add_library(base-lib + convert_to.cpp errno_string.cpp mem_utils.cpp mutex.cpp) diff --git a/src/base/convert_to.cpp b/src/base/convert_to.cpp new file mode 100644 index 000000000..9e4274a5c --- /dev/null +++ b/src/base/convert_to.cpp @@ -0,0 +1,23 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#include "config.h" + +#include + +#include "base/convert_to.h" + +template<> int base::convert_to(const base::string& from) +{ + return std::strtol(from.c_str(), NULL, 10); +} + +template<> base::string base::convert_to(const int& from) +{ + char buf[32]; + std::sprintf(buf, "%d", from); + return buf; +} diff --git a/src/base/convert_to.h b/src/base/convert_to.h new file mode 100644 index 000000000..67e84048c --- /dev/null +++ b/src/base/convert_to.h @@ -0,0 +1,25 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef BASE_CONVERT_TO_H_INCLUDED +#define BASE_CONVERT_TO_H_INCLUDED + +#include "base/string.h" + +namespace base { + + // Undefined convertion + template + To convert_to(const From& from) { + enum { not_supported = 1/(1 == 0) }; // static_assert(false) + } + + template<> int convert_to(const base::string& from); + template<> base::string convert_to(const int& from); + +} + +#endif diff --git a/src/base/split_string.h b/src/base/split_string.h new file mode 100644 index 000000000..614e3745e --- /dev/null +++ b/src/base/split_string.h @@ -0,0 +1,57 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef BASE_SPLIT_STRING_H_INCLUDED +#define BASE_SPLIT_STRING_H_INCLUDED + +#include +#include + +namespace base { + + namespace details { + + template + struct is_separator { + const T* separators; + is_separator(const T* separators) : separators(separators) { } + bool operator()(typename T::value_type chr) + { + for (typename T::const_iterator + it = separators->begin(), + end = separators->end(); it != end; ++it) { + if (chr == *it) + return true; + } + return false; + } + }; + + } + + template + void split_string(const T& string, std::vector& parts, const T& separators) + { + size_t elements = 1 + std::count_if(string.begin(), string.end(), details::is_separator(&separators)); + parts.reserve(elements); + + size_t beg = 0, end; + while (true) { + end = string.find_first_of(separators, beg); + if (end != T::npos) { + parts.push_back(string.substr(beg, end - beg)); + beg = end+1; + } + else { + parts.push_back(string.substr(beg)); + break; + } + } + } + +} + +#endif diff --git a/src/base/split_string_unittest.cpp b/src/base/split_string_unittest.cpp new file mode 100644 index 000000000..bb0a1346f --- /dev/null +++ b/src/base/split_string_unittest.cpp @@ -0,0 +1,47 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#include "tests/test.h" + +#include +#include + +#include "base/split_string.h" + +TEST(SplitString, Empty) +{ + std::vector result; + base::split_string("", result, ","); + ASSERT_EQ(1, result.size()); + EXPECT_EQ("", result[0]); +} + +TEST(SplitString, NoSeparator) +{ + std::vector result; + base::split_string("Hello,World", result, ""); + ASSERT_EQ(1, result.size()); + EXPECT_EQ("Hello,World", result[0]); +} + +TEST(SplitString, OneSeparator) +{ + std::vector result; + base::split_string("Hello,World", result, ","); + ASSERT_EQ(2, result.size()); + EXPECT_EQ("Hello", result[0]); + EXPECT_EQ("World", result[1]); +} + +TEST(SplitString, MultipleSeparators) +{ + std::vector result; + base::split_string("Hello,World", result, ",r"); + ASSERT_EQ(3, result.size()); + EXPECT_EQ("Hello", result[0]); + EXPECT_EQ("Wo", result[1]); + EXPECT_EQ("ld", result[2]); +} diff --git a/src/base/string.h b/src/base/string.h new file mode 100644 index 000000000..86059fc63 --- /dev/null +++ b/src/base/string.h @@ -0,0 +1,18 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef BASE_STRING_H_INCLUDED +#define BASE_STRING_H_INCLUDED + +#include + +namespace base { + +typedef std::string string; + +} + +#endif diff --git a/src/check_args.cpp b/src/check_args.cpp index e4c006fe5..323819040 100644 --- a/src/check_args.cpp +++ b/src/check_args.cpp @@ -18,21 +18,17 @@ #include "config.h" -#include "Vaca/Application.h" -#include "Vaca/String.h" - +#include "base/convert_to.h" +#include "base/split_string.h" +#include "base/string.h" #include "check_args.h" #include "console.h" #include "core/cfg.h" -using namespace Vaca; - -CheckArgs::CheckArgs() +CheckArgs::CheckArgs(const std::vector& args) : m_consoleOnly(false) , m_verbose(false) { - const std::vector& args(Application::getArgs()); - // Exe name m_exeName = args[0]; @@ -41,40 +37,40 @@ CheckArgs::CheckArgs() size_t i, n, len; for (i=1; i 0) && (len > 0)) { - String option = arg.substr(n); + base::string option = arg.substr(n); // Use other palette file - if (option == L"palette") { + if (option == "palette") { if (++i < args.size()) m_paletteFilename = args[i]; else usage(false); } // Video resolution - else if (option == L"resolution") { + else if (option == "resolution") { if (++i < args.size()) { // The following argument should indicate the resolution // in a format like: 320x240[x8] - std::vector parts; - split_string(args[i], parts, L"x"); + std::vector parts; + base::split_string(args[i], parts, "x"); switch (parts.size()) { case 1: - set_config_int("GfxMode", "Depth", convert_to(parts[0])); + set_config_int("GfxMode", "Depth", base::convert_to(parts[0])); break; case 2: case 3: - set_config_int("GfxMode", "Width", convert_to(parts[0])); - set_config_int("GfxMode", "Height", convert_to(parts[1])); + set_config_int("GfxMode", "Width", base::convert_to(parts[0])); + set_config_int("GfxMode", "Height", base::convert_to(parts[1])); if (parts.size() == 3) - set_config_int("GfxMode", "Depth", convert_to(parts[2])); + set_config_int("GfxMode", "Depth", base::convert_to(parts[2])); break; default: usage(false); @@ -88,15 +84,15 @@ CheckArgs::CheckArgs() } } // Verbose mode - else if (option == L"verbose") { + else if (option == "verbose") { m_verbose = true; } // Show help - else if (option == L"help") { + else if (option == "help") { usage(true); } // Show version - else if (option == L"version") { + else if (option == "version") { m_consoleOnly = true; console.printf("%s %s\n", PACKAGE, VERSION); } diff --git a/src/check_args.h b/src/check_args.h index 1c11a075a..18a793df0 100644 --- a/src/check_args.h +++ b/src/check_args.h @@ -19,10 +19,8 @@ #ifndef CHECK_ARGS_H_INCLUDED #define CHECK_ARGS_H_INCLUDED -#include "Vaca/String.h" #include - -using Vaca::String; +#include "base/string.h" // Parses the input arguments in the command line. class CheckArgs @@ -33,23 +31,23 @@ public: class Option { int m_type; - String m_data; + base::string m_data; public: enum { OpenSprite, }; - Option(int type, const String& data) : m_type(type), m_data(data) { } + Option(int type, const base::string& data) : m_type(type), m_data(data) { } int type() const { return m_type; } - const String& data() const { return m_data; } + const base::string& data() const { return m_data; } }; typedef std::vector Options; typedef Options::iterator iterator; - CheckArgs(); + CheckArgs(const std::vector& args); ~CheckArgs(); void clear(); @@ -57,7 +55,7 @@ public: iterator begin() { return m_options.begin(); } iterator end() { return m_options.end(); } - String getPaletteFilename() const { return m_paletteFilename; } + base::string getPaletteFilename() const { return m_paletteFilename; } bool isConsoleOnly() const { return m_consoleOnly; } bool isVerbose() const { return m_verbose; } @@ -66,8 +64,8 @@ private: void usage(bool showHelp); Options m_options; - String m_paletteFilename; - String m_exeName; + base::string m_paletteFilename; + base::string m_exeName; bool m_consoleOnly; bool m_verbose; }; diff --git a/src/commands/cmd_check_updates.cpp b/src/commands/cmd_check_updates.cpp index 1897acb9b..5dc86abac 100644 --- a/src/commands/cmd_check_updates.cpp +++ b/src/commands/cmd_check_updates.cpp @@ -19,8 +19,9 @@ #include "config.h" #include -#include +#include "base/convert_to.h" +#include "base/string.h" #include "commands/command.h" #include "launcher.h" @@ -87,11 +88,11 @@ void CheckUpdatesCommand::onExecute(Context* context) // Version of the operating system if (os_version >= 0) { url += "&osver="; - url += Vaca::convert_to(os_version); + url += base::convert_to(os_version); } if (os_revision >= 0) { url += "&osrev="; - url += Vaca::convert_to(os_revision); + url += base::convert_to(os_revision); } Launcher::openUrl(url); diff --git a/src/main.cpp b/src/main.cpp index 7acd12434..3bb68bb9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,10 @@ #include "app.h" #include "loadpng.h" +#ifdef WIN32 +#include +#endif + ////////////////////////////////////////////////////////////////////// // Information for "ident". @@ -56,15 +60,19 @@ public: } }; -// ASE entry point (this function is called from Vaca library) -int vaca_main() +// ASE entry point +int main(int argc, char* argv[]) { +#ifdef WIN32 + CoInitialize(NULL); +#endif + int status = 1; // 1 = error Allegro allegro; try { Jinete jinete; - App app; + App app(argc, argv); status = app.run(); } @@ -83,4 +91,5 @@ int vaca_main() return status; } -#include "Vaca/main.h" +END_OF_MAIN(); + diff --git a/third_party/vaca/CMakeLists.txt b/third_party/vaca/CMakeLists.txt index 10bb3350e..391c168a1 100644 --- a/third_party/vaca/CMakeLists.txt +++ b/third_party/vaca/CMakeLists.txt @@ -4,12 +4,9 @@ include_directories(include ../../src) add_library(vaca - src/Application.cpp src/Component.cpp src/Event.cpp src/Exception.cpp src/PreferredSizeEvent.cpp src/Property.cpp - src/Referenceable.cpp - src/String.cpp - src/Vaca.cpp) + src/Referenceable.cpp) diff --git a/third_party/vaca/include/Vaca/Application.h b/third_party/vaca/include/Vaca/Application.h deleted file mode 100644 index be5ab5c3c..000000000 --- a/third_party/vaca/include/Vaca/Application.h +++ /dev/null @@ -1,86 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of the author nor the names of its contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef VACA_APPLICATION_H -#define VACA_APPLICATION_H - -#include "Vaca/base.h" -#include - -namespace Vaca { - - namespace details { - class VACA_DLL MainArgs - { - public: - static void setArgs(int, char**); - }; - } - -/** - The main class of Vaca: initializes and destroys the GUI library - resources. - - A program that uses Vaca library must to create one instance of - this class, or an instance of a derived class. -*/ -class VACA_DLL Application -{ -public: - - Application(); - virtual ~Application(); - - static size_t getArgc(); - static const String& getArgv(size_t i); - static const std::vector& getArgs(); - - static Application* getInstance(); - -private: - - friend class details::MainArgs; - - /** - The singleton, the only instance of Application (or a class - derived from Application) that a program can contain. - */ - static Application* m_instance; - - static std::vector m_args; - - static void setArgs(const std::vector& args); - -}; - -} // namespace Vaca - -#endif // VACA_APPLICATION_H diff --git a/third_party/vaca/src/Application.cpp b/third_party/vaca/src/Application.cpp deleted file mode 100644 index 3e6c2bc7d..000000000 --- a/third_party/vaca/src/Application.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of the author nor the names of its contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "Vaca/Application.h" -#include -#include - -#ifdef VACA_ON_WINDOWS -#include -#endif - -using namespace Vaca; - -Application* Application::m_instance = NULL; -std::vector Application::m_args; - -Application::Application() -{ -#ifdef VACA_ON_WINDOWS - CoInitialize(NULL); -#endif -} - -Application::~Application() -{ -} - -size_t Application::getArgc() -{ - return m_args.size(); -} - -const String& Application::getArgv(size_t i) -{ - return m_args[i]; -} - -/** - Returns the parameters in the command line. - - @c Application::getArgs()[0] is the name of the executable file. -*/ -const std::vector& Application::getArgs() -{ - return m_args; -} - -void Application::setArgs(const std::vector& args) -{ - m_args = args; -} - -/** - Returns the Application's singleton. - - A program using Vaca must have one instance of Applicaton or a - class derived from it. -*/ -Application* Application::getInstance() -{ - assert(m_instance != NULL); - return m_instance; -} diff --git a/third_party/vaca/src/String.cpp b/third_party/vaca/src/String.cpp index 4f2ef3807..aa9e5650b 100644 --- a/third_party/vaca/src/String.cpp +++ b/third_party/vaca/src/String.cpp @@ -128,43 +128,6 @@ String Vaca::trim_string(const Char* str) return res; } -namespace { - struct is_separator - { - const String* separators; - is_separator(const String* separators) : separators(separators) { } - bool operator()(Char chr) - { - for (String::const_iterator - it = separators->begin(), - end = separators->end(); it != end; ++it) { - if (chr == *it) - return true; - } - return false; - } - }; -} - -void Vaca::split_string(const String& string, std::vector& parts, const String& separators) -{ - size_t elements = 1 + std::count_if(string.begin(), string.end(), is_separator(&separators)); - parts.resize(elements); - - size_t beg = 0, end; - while (true) { - end = string.find_first_of(separators); - if (end != String::npos) { - parts.push_back(string.substr(beg, end - beg)); - beg = end+1; - } - else { - parts.push_back(string.substr(beg)); - break; - } - } -} - template<> int Vaca::convert_to(const String& from) { return (int)std::wcstol(from.c_str(), NULL, 10); diff --git a/third_party/vaca/src/Vaca.cpp b/third_party/vaca/src/Vaca.cpp deleted file mode 100644 index 188d005d9..000000000 --- a/third_party/vaca/src/Vaca.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of the author nor the names of its contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "Vaca/base.h" -#include "Vaca/Application.h" - -#if defined(VACA_WINDOWS) - #include "win32/MainArgs.h" -#else - #include "std/MainArgs.h" -#endif diff --git a/third_party/vaca/src/std/MainArgs.h b/third_party/vaca/src/std/MainArgs.h deleted file mode 100644 index 25693e184..000000000 --- a/third_party/vaca/src/std/MainArgs.h +++ /dev/null @@ -1,42 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of the author nor the names of its contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "Vaca/String.h" - -void Vaca::details::MainArgs::setArgs(int argc, char* argv[]) -{ - std::vector args; - args.reserve(argc); - for (int i=0; i(argv[i])); - - Application::setArgs(args); -} diff --git a/third_party/vaca/src/win32/MainArgs.h b/third_party/vaca/src/win32/MainArgs.h deleted file mode 100644 index 110accb6d..000000000 --- a/third_party/vaca/src/win32/MainArgs.h +++ /dev/null @@ -1,51 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of the author nor the names of its contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#include - -void Vaca::details::MainArgs::setArgs(int, char**) -{ - // Convert the command-line to a vector of arguments using Win32 API - std::vector args; - LPWSTR* arglist; - int argc; - - arglist = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - if (arglist != NULL) { - args.reserve(argc); - for (int i=0; i