]> git.sesse.net Git - casparcg/blobdiff - common/env.cpp
2.0.2: - Updated to use std::wstring more consistently.
[casparcg] / common / env.cpp
index 209e530c77408f9f6da3b18d1df7fb0b92d57cfe..3616397e46e0c04d97973dbf702479dbe059a862 100644 (file)
@@ -1,22 +1,24 @@
 /*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
 *\r
-*  This file is part of CasparCG.\r
+* This file is part of CasparCG (www.casparcg.com).\r
 *\r
-*    CasparCG is free software: you can redistribute it and/or modify\r
-*    it under the terms of the GNU General Public License as published by\r
-*    the Free Software Foundation, either version 3 of the License, or\r
-*    (at your option) any later version.\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
 *\r
-*    CasparCG is distributed in the hope that it will be useful,\r
-*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*    GNU General Public License for more details.\r
-\r
-*    You should have received a copy of the GNU General Public License\r
-*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
 *\r
+* Author: Robert Nagy, ronag89@gmail.com\r
 */\r
+\r
 #include "stdafx.h"\r
 \r
 #include "env.h"\r
@@ -41,9 +43,8 @@ using namespace boost::filesystem2;
 std::wstring media;\r
 std::wstring log;\r
 std::wstring ftemplate;\r
-std::wstring ftemplate_host;\r
 std::wstring data;\r
-boost::property_tree::ptree pt;\r
+boost::property_tree::wptree pt;\r
 \r
 void check_is_configured()\r
 {\r
@@ -51,22 +52,20 @@ void check_is_configured()
                BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Enviroment properties has not been configured"));\r
 }\r
 \r
-void configure(const std::string& filename)\r
+void configure(const std::wstring& filename)\r
 {\r
        try\r
        {\r
-               std::string initialPath = boost::filesystem::initial_path().file_string();\r
+               auto initialPath = boost::filesystem::initial_path<boost::filesystem2::wpath>().file_string();\r
        \r
-               boost::property_tree::read_xml(initialPath + "\\" + filename, pt);\r
-\r
-               auto paths = pt.get_child("configuration.paths");\r
-               media = widen(paths.get("media-path", initialPath + "\\media\\"));\r
-               log = widen(paths.get("log-path", initialPath + "\\log\\"));\r
-               ftemplate = complete(wpath(widen(paths.get("template-path", initialPath + "\\template\\")))).string();\r
-\r
-               ftemplate_host = widen(paths.get("template-host", "cg.fth"));\r
-\r
-               data = widen(paths.get("data-path", initialPath + "\\data\\"));\r
+               std::wifstream file(initialPath + L"\\" + filename);\r
+               boost::property_tree::read_xml(file, pt, boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments);\r
+\r
+               auto paths = pt.get_child(L"configuration.paths");\r
+               media = widen(paths.get(L"media-path", initialPath + L"\\media\\"));\r
+               log = widen(paths.get(L"log-path", initialPath + L"\\log\\"));\r
+               ftemplate = complete(wpath(widen(paths.get(L"template-path", initialPath + L"\\template\\")))).string();                \r
+               data = widen(paths.get(L"data-path", initialPath + L"\\data\\"));\r
        }\r
        catch(...)\r
        {\r
@@ -93,12 +92,6 @@ const std::wstring& template_folder()
        return ftemplate;\r
 }\r
 \r
-const std::wstring& template_host()\r
-{\r
-       check_is_configured();\r
-       return ftemplate_host;\r
-}\r
-\r
 const std::wstring& data_folder()\r
 {\r
        check_is_configured();\r
@@ -107,11 +100,11 @@ const std::wstring& data_folder()
 \r
 const std::wstring& version()\r
 {\r
-       static std::wstring ver = std::wstring(L"") + CASPAR_GEN + L"." + CASPAR_MAYOR + L"." + CASPAR_MINOR + L"." + CASPAR_REV + L" ALPHA";\r
+       static std::wstring ver = std::wstring(L"") + CASPAR_GEN + L"." + CASPAR_MAYOR + L"." + CASPAR_MINOR + L"." + CASPAR_REV + L" " + CASPAR_TAG;\r
        return ver;\r
 }\r
 \r
-const boost::property_tree::ptree& properties()\r
+const boost::property_tree::wptree& properties()\r
 {\r
        check_is_configured();\r
        return pt;\r