// // ProGen.cpp // // $Id: //poco/1.4/ProGen/src/ProGen.cpp#9 $ // // Visual Studio project file generator. // // Copyright (c) 2010, Applied Informatics Software Engineering GmbH. // and Contributors. // // Permission is hereby granted, free of charge, to any person or organization // obtaining a copy of the software and accompanying documentation covered by // this license (the "Software") to use, reproduce, display, distribute, // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // // The copyright notices in the Software and this entire statement, including // the above license grant, this restriction and the following disclaimer, // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // #include "Poco/Util/Application.h" #include "Poco/Util/Option.h" #include "Poco/Util/OptionSet.h" #include "Poco/Util/HelpFormatter.h" #include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/MapConfiguration.h" #include "Poco/Util/PropertyFileConfiguration.h" #include "Poco/DOM/Document.h" #include "Poco/DOM/Element.h" #include "Poco/DOM/NamedNodeMap.h" #include "Poco/DOM/Attr.h" #include "Poco/DOM/Text.h" #include "Poco/DOM/DOMParser.h" #include "Poco/DOM/DOMSerializer.h" #include "Poco/DOM/DOMWriter.h" #include "Poco/DOM/TreeWalker.h" #include "Poco/DOM/NodeFilter.h" #include "Poco/DOM/NodeList.h" #include "Poco/XML/XMLWriter.h" #include "Poco/Windows1252Encoding.h" #include "Poco/AutoPtr.h" #include "Poco/FileStream.h" #include "Poco/Path.h" #include "Poco/File.h" #include "Poco/StringTokenizer.h" #include "Poco/UUIDGenerator.h" #include "Poco/UUID.h" #include "Poco/String.h" #include "Poco/Process.h" #include "VSXMLWriter.h" #include #include using Poco::Util::Application; using Poco::Util::Option; using Poco::Util::OptionSet; using Poco::Util::HelpFormatter; using Poco::Util::AbstractConfiguration; using Poco::Util::OptionCallback; using Poco::AutoPtr; using Poco::FileInputStream; using Poco::FileOutputStream; using Poco::Path; using Poco::StringTokenizer; class ProGenApp: public Application { public: ProGenApp(): _helpRequested(false), _outputDir(Poco::Path::current()) { } protected: void initialize(Application& self) { loadConfiguration(); // load default configuration files, if present Application::initialize(self); } void defineOptions(OptionSet& options) { Application::defineOptions(options); options.addOption( Option("help", "h", "Display help information on command line arguments.") .required(false) .repeatable(false) .callback(OptionCallback(this, &ProGenApp::handleHelp))); options.addOption( Option("define", "D", "Define a configuration property. A configuration property " "defined with this option can be referenced in the project " "properties file, using the following syntax: ${}.") .required(false) .repeatable(true) .argument("=") .callback(OptionCallback(this, &ProGenApp::handleDefine))); options.addOption( Option("output-dir", "o", "Write project files to directory .") .required(false) .repeatable(false) .argument("") .callback(OptionCallback(this, &ProGenApp::handleOutputDir))); options.addOption( Option("platform", "p", "Generate project files for specified platforms only.") .required(false) .repeatable(true) .argument("{,}") .callback(OptionCallback(this, &ProGenApp::handlePlatform))); options.addOption( Option("tool", "t", "Generate project files for specified tools only.") .required(false) .repeatable(true) .argument("{,}") .callback(OptionCallback(this, &ProGenApp::handleTool))); } void handleHelp(const std::string& name, const std::string& value) { _helpRequested = true; stopOptionsProcessing(); } void handleDefine(const std::string& name, const std::string& value) { defineProperty(value); } void handleOutputDir(const std::string& name, const std::string& value) { _outputDir = value; } void handlePlatform(const std::string& name, const std::string& value) { Poco::StringTokenizer tok(value, ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY); _platforms.insert(tok.begin(), tok.end()); } void handleTool(const std::string& name, const std::string& value) { Poco::StringTokenizer tok(value, ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY); _tools.insert(tok.begin(), tok.end()); } void displayHelp() { HelpFormatter helpFormatter(options()); helpFormatter.setCommand(commandName()); helpFormatter.setUsage("[