diff --git a/CMakeLists.txt b/CMakeLists.txt index 11d187bba5..91cd211a10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ project(lxgui) # setup version numbers set(VERSION_MAJOR 1) -set(VERSION_MINOR 1) +set(VERSION_MINOR 2) # check compiler version for C++11 features if(CMAKE_COMPILER_IS_GNUCXX) @@ -34,12 +34,12 @@ if(CMAKE_COMPILER_IS_GNUCXX) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) - + string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION}) list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR) list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR) - set(GCC_VERSION ${GCC_MAJOR}.${GCC_MINOR}) - + set(GCC_VERSION ${GCC_MAJOR}.${GCC_MINOR}) + if(GCC_VERSION VERSION_EQUAL 4.6) message(STATUS "gcc version >= 4.6 (${GCC_VERSION})") add_definitions(-std=c++0x) @@ -58,28 +58,54 @@ elseif(MSVC) if(CMAKE_BUILD_TYPE MATCHES Debug) add_definitions(/Zi) endif() - - if(MSVC_VERSION VERSION_EQUAL 1600) - add_definitions(/DNO_CPP11_EXPLICIT_CONV) - add_definitions(/DNO_CPP11_DELETE_FUNCTION) - add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT) - add_definitions(/DNO_CPP11_CONSTEXPR) - add_definitions(/DNO_CPP11_UNICODE_LITTERAL) - add_definitions(/D_CRT_SECURE_NO_DEPRECATE) + + add_definitions(/DNO_CPP11_EXPLICIT_CONV) + add_definitions(/DNO_CPP11_DELETE_FUNCTION) + add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT) + add_definitions(/DNO_CPP11_CONSTEXPR) + add_definitions(/DNO_CPP11_UNICODE_LITTERAL) + add_definitions(/D_CRT_SECURE_NO_DEPRECATE) + + if(NOT (MSVC_VERSION VERSION_LESS 1600)) message(STATUS "Using MSVC 2010: some C++11 features are not supported by this compiler. Workarounds are used but never perfectly mimic the C++11 code.") - elseif(MSVC_VERSION VERSION_GREATER 1600) - add_definitions(/DNO_CPP11_EXPLICIT_CONV) - add_definitions(/DNO_CPP11_DELETE_FUNCTION) - add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT) - add_definitions(/DNO_CPP11_CONSTEXPR) - add_definitions(/DNO_CPP11_UNICODE_LITTERAL) - add_definitions(/D_CRT_SECURE_NO_DEPRECATE) - message(STATUS "Using MSVC > 2010: some C++11 features are not supported by this compiler. Workarounds are used but never perfectly mimic the C++11 code.") else() message(ERROR ": lxgui requires advanced features from the C++11 norm that are only available with MSVC 2010 or higher (your version: ${MSVC_VERSION}). Please upgrade your compiler.") endif() +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.99) + message(STATUS "clang version >= 3.0 (${CMAKE_CXX_COMPILER_VERSION})") + else() + message(ERROR ": lxgui requires advanced features from the C++11 norm that are only available with clang 3.0 or higher (your version: ${CMAKE_CXX_COMPILER_VERSION}). Please upgrade your compiler.") + endif() + + add_definitions(-Weverything) + add_definitions(-Wno-c++98-compat-pedantic) + add_definitions(-Wno-c++98-compat) + add_definitions(-Wno-unused-parameter) + add_definitions(-Wno-sign-conversion) + add_definitions(-Wno-conversion) + add_definitions(-Wno-missing-variable-declarations) + add_definitions(-Wno-missing-prototypes) + add_definitions(-Wno-padded) + add_definitions(-Wno-float-equal) + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-global-constructors) + add_definitions(-Wno-exit-time-destructors) + add_definitions(-Wno-weak-vtables) + add_definitions(-Wno-covered-switch-default) + add_definitions(-Wno-documentation-unknown-command) + add_definitions(-Wno-unneeded-internal-declaration) + add_definitions(-Wno-unused-function) + add_definitions(-Wno-unused-macros) + add_definitions(-Wno-switch-enum) + if(CMAKE_BUILD_TYPE MATCHES Debug) + add_definitions(-g) + else() + add_definitions(-O3) + endif() + add_definitions(-std=c++11) else() - message(STATUS "Warning: your compiler has not been setup by the CMake script, do not expect it to work") + message(WARNING "Warning: your compiler has not been setup by the CMake script, do not expect it to work") endif() # set OS preprocessor defines diff --git a/gui/src/gui_frame.cpp b/gui/src/gui_frame.cpp index 441d8691cd..9995c6f066 100644 --- a/gui/src/gui_frame.cpp +++ b/gui/src/gui_frame.cpp @@ -1070,9 +1070,9 @@ void frame::notify_script_defined(const std::string& sScriptName, bool bDefined) if (bDefined) { - std::map::iterator iter = lDefinedHandlerList_.find(sScriptName); - if (iter != lDefinedHandlerList_.end()) - lDefinedHandlerList_.erase(iter); + std::map::iterator iter2 = lDefinedHandlerList_.find(sScriptName); + if (iter2 != lDefinedHandlerList_.end()) + lDefinedHandlerList_.erase(iter2); lDefinedScriptList_[sCutScriptName] = ""; } else @@ -1330,14 +1330,14 @@ void frame::on(const std::string& sScriptName, event* pEvent) // that will print the actual line numbers in the XML file. pErrorFunc = pLua->get_lua_error_function(); - std::map::const_iterator iter = lXMLScriptInfoList_.find(sScriptName); - if (iter != lXMLScriptInfoList_.end()) + std::map::const_iterator iter2 = lXMLScriptInfoList_.find(sScriptName); + if (iter2 != lXMLScriptInfoList_.end()) { sFile = pLua->get_global_string("_xml_file_name", false, ""); uiLineNbr = pLua->get_global_int("_xml_line_nbr", false, 0); - pLua->push_string(iter->second.sFile); pLua->set_global("_xml_file_name"); - pLua->push_number(iter->second.uiLineNbr); pLua->set_global("_xml_line_nbr"); + pLua->push_string(iter2->second.sFile); pLua->set_global("_xml_file_name"); + pLua->push_number(iter2->second.uiLineNbr); pLua->set_global("_xml_line_nbr"); pLua->set_lua_error_function(l_xml_error); } @@ -1561,7 +1561,7 @@ void frame::set_parent(uiobject* pParent) gui::out << gui::error << "gui::" << lType_.back() << " : Cannot call set_parent(this)." << std::endl; return; } - + if (pParent != pParent_) { if (!pParentFrame_ && uiID_ != uint(-1)) diff --git a/gui/src/gui_frame_glues.cpp b/gui/src/gui_frame_glues.cpp index de823f539c..0036a9f0d2 100644 --- a/gui/src/gui_frame_glues.cpp +++ b/gui/src/gui_frame_glues.cpp @@ -722,7 +722,7 @@ int lua_frame::_register_event(lua_State* pLua) int lua_frame::_register_for_drag(lua_State* pLua) { if (!check_parent_()) - return 0; + return 0; lua::function mFunc("Frame:register_for_drag", pLua); mFunc.add(0, "button 1", lua::TYPE_STRING, true); @@ -733,7 +733,7 @@ int lua_frame::_register_for_drag(lua_State* pLua) std::vector lButtonList; for (uint i = 0; i < 3; ++i) { - if (mFunc.is_provided(i)) + if (mFunc.is_provided(i)) lButtonList.push_back(mFunc.get(i)->get_string()); else break; @@ -891,7 +891,7 @@ int lua_frame::_set_backdrop_color(lua_State* pLua) } } else - mColor = color(mFunc.get(0)->get_string()); + mColor = color(mFunc.get(0)->get_string()); pBackdrop->set_background_color(mColor); } @@ -1121,18 +1121,18 @@ int lua_frame::_set_script(lua_State* pLua) std::string sScriptName = mFunc.get(0)->get_string(); if (pFrameParent_->can_use_script(sScriptName)) { - lua::state* pLua = mFunc.get_state(); + lua::state* pState = mFunc.get_state(); utils::wptr pArg = mFunc.get(1); if (pArg->is_provided() && pArg->get_type() == lua::TYPE_FUNCTION) { - pLua->push_value(pArg->get_index()); - pLua->set_global(pFrameParent_->get_name() + ":" + sScriptName); + pState->push_value(pArg->get_index()); + pState->set_global(pFrameParent_->get_name() + ":" + sScriptName); pFrameParent_->notify_script_defined(sScriptName, true); } else { - pLua->push_nil(); - pLua->set_global(pFrameParent_->get_name() + ":" + sScriptName); + pState->push_nil(); + pState->set_global(pFrameParent_->get_name() + ":" + sScriptName); pFrameParent_->notify_script_defined(sScriptName, false); } } diff --git a/gui/src/gui_manager.cpp b/gui/src/gui_manager.cpp index aa76a485ce..42eb225e4e 100644 --- a/gui/src/gui_manager.cpp +++ b/gui/src/gui_manager.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include namespace gui @@ -25,8 +25,8 @@ namespace gui int l_set_key_binding(lua_State* pLua); int l_create_frame(lua_State* pLua); int l_delete_frame(lua_State* pLua); -int l_get_locale(lua_State* pLua); -int l_log(lua_State* pLua); +int l_get_locale(lua_State* pLua); +int l_log(lua_State* pLua); manager::manager(const input::handler& mInputHandler, const std::string& sLocale, uint uiScreenWidth, uint uiScreenHeight, utils::refptr pImpl) : @@ -45,9 +45,9 @@ manager::manager(const input::handler& mInputHandler, const std::string& sLocale pRenderTarget_(nullptr), sLocale_(sLocale), pImpl_(pImpl) { pEventManager_ = utils::refptr(new event_manager()); - event_receiver::pEventManager_ = pEventManager_.get(); + event_receiver::pEventManager_ = pEventManager_.get(); pInputManager_->register_event_manager(pEventManager_); - register_event("KEY_PRESSED"); + register_event("KEY_PRESSED"); pImpl_->set_parent(this); } @@ -409,7 +409,7 @@ void manager::notify_object_has_parent(uiobject* pObj) } const uiobject* manager::get_uiobject(uint uiID) const -{ +{ std::map::const_iterator iter = lObjectList_.find(uiID); if (iter != lObjectList_.end()) return iter->second; @@ -418,7 +418,7 @@ const uiobject* manager::get_uiobject(uint uiID) const } uiobject* manager::get_uiobject(uint uiID) -{ +{ std::map::iterator iter = lObjectList_.find(uiID); if (iter != lObjectList_.end()) return iter->second; @@ -429,7 +429,7 @@ uiobject* manager::get_uiobject(uint uiID) const uiobject* manager::get_uiobject_by_name(const std::string& sName, bool bVirtual) const { if (bVirtual) - { + { std::map::const_iterator iter = lNamedVirtualObjectList_.find(sName); if (iter != lNamedVirtualObjectList_.end()) return iter->second; @@ -437,7 +437,7 @@ const uiobject* manager::get_uiobject_by_name(const std::string& sName, bool bVi return nullptr; } else - { + { std::map::const_iterator iter = lNamedObjectList_.find(sName); if (iter != lNamedObjectList_.end()) return iter->second; @@ -449,7 +449,7 @@ const uiobject* manager::get_uiobject_by_name(const std::string& sName, bool bVi uiobject* manager::get_uiobject_by_name(const std::string& sName, bool bVirtual) { if (bVirtual) - { + { std::map::iterator iter = lNamedVirtualObjectList_.find(sName); if (iter != lNamedVirtualObjectList_.end()) return iter->second; @@ -457,7 +457,7 @@ uiobject* manager::get_uiobject_by_name(const std::string& sName, bool bVirtual) return nullptr; } else - { + { std::map::iterator iter = lNamedObjectList_.find(sName); if (iter != lNamedObjectList_.end()) return iter->second; @@ -490,8 +490,8 @@ void manager::load_addon_toc_(const std::string& sAddOnName, const std::string& { std::string sLine; getline(mFile, sLine); if (sLine.empty()) - continue; - + continue; + utils::replace(sLine, "\r", ""); if (sLine[0] == '#' && sLine[1] == '#') { @@ -506,15 +506,15 @@ void manager::load_addon_toc_(const std::string& sAddOnName, const std::string& utils::trim(sValue, ' '); if (sKey == "Interface") { - mAddOn.sUIVersion = sValue; + mAddOn.sUIVersion = sValue; if (mAddOn.sUIVersion == sUIVersion_) mAddOn.bEnabled = true; else { gui::out << gui::warning << "gui::manager : " - << "Wrong UI version for \"" << sAddOnName << "\" (got : " - << mAddOn.sUIVersion << ", expected : " << sUIVersion_ + << "Wrong UI version for \"" << sAddOnName << "\" (got : " + << mAddOn.sUIVersion << ", expected : " << sUIVersion_ << "). AddOn disabled." << std::endl; mAddOn.bEnabled = false; } @@ -620,10 +620,10 @@ void manager::load_addon_directory_(const std::string& sDirectory) { while (!mFile.eof()) { - std::string sLine; getline(mFile, sLine); - if (sLine.empty()) - continue; - + std::string sLine; getline(mFile, sLine); + if (sLine.empty()) + continue; + utils::replace(sLine, "\r", ""); if (sLine[0] == '#') { @@ -642,17 +642,17 @@ void manager::load_addon_directory_(const std::string& sDirectory) std::string sKey = lArgs[0]; utils::trim(sKey, ' '); std::string sValue = lArgs[1]; - utils::trim(sValue, ' '); - auto iter = lAddOns.find(sKey); - if (iter != lAddOns.end()) + utils::trim(sValue, ' '); + auto iter2 = lAddOns.find(sKey); + if (iter2 != lAddOns.end()) { if (bCore) - lCoreAddOnStack.push_back(&iter->second); + lCoreAddOnStack.push_back(&iter2->second); else - lAddOnStack.push_back(&iter->second); + lAddOnStack.push_back(&iter2->second); - if (sValue != "1") - iter->second.bEnabled = false; + if (sValue != "1") + iter2->second.bEnabled = false; } } } @@ -668,7 +668,7 @@ void manager::load_addon_directory_(const std::string& sDirectory) } foreach (iterAddon, lAddOnStack) - { + { if ((*iterAddon)->bEnabled) this->load_addon_files_(*iterAddon); } @@ -679,14 +679,14 @@ void manager::load_addon_directory_(const std::string& sDirectory) void manager::save_variables_(addon* pAddOn) { if (!pAddOn->lSavedVariableList.empty()) - { - if (!utils::make_directory("saves/interface/"+pAddOn->sMainDirectory)) - { - gui::out << gui::error << "gui::manager : " - "unable to create directory 'saves/interface/" << - pAddOn->sMainDirectory << "'" << std::endl; - return; - } + { + if (!utils::make_directory("saves/interface/"+pAddOn->sMainDirectory)) + { + gui::out << gui::error << "gui::manager : " + "unable to create directory 'saves/interface/" << + pAddOn->sMainDirectory << "'" << std::endl; + return; + } std::ofstream mFile("saves/interface/"+pAddOn->sMainDirectory+"/"+pAddOn->sName+".lua"); std::vector::iterator iterVariable; @@ -697,18 +697,18 @@ void manager::save_variables_(addon* pAddOn) mFile << sVariable << "\n"; } } -} - -void gui_out(const std::string& sMessage) -{ - gui::out << sMessage << std::endl; +} + +void gui_out(const std::string& sMessage) +{ + gui::out << sMessage << std::endl; } void manager::create_lua(std::function pLuaRegs) { if (!pLua_) { - pLua_ = utils::refptr(new lua::state()); + pLua_ = utils::refptr(new lua::state()); pLua_->set_print_error_function(gui_out); register_lua_manager_(); @@ -721,7 +721,7 @@ void manager::create_lua(std::function pLuaRegs) pLua_->reg("set_key_binding", l_set_key_binding); pLua_->reg("create_frame", l_create_frame); pLua_->reg("delete_frame", l_delete_frame); - pLua_->reg("get_locale", l_get_locale); + pLua_->reg("get_locale", l_get_locale); pLua_->reg("log", l_log); pLuaRegs_ = pLuaRegs; @@ -858,15 +858,15 @@ void manager::render_ui() const { if (bEnableCaching_) { - if (pSprite_) - { + if (pSprite_) + { begin(); - pSprite_->render(0, 0); - end(); + pSprite_->render(0, 0); + end(); } } else - { + { begin(); std::map::const_iterator iterStrata; foreach (iterStrata, lStrataList_) @@ -887,7 +887,7 @@ void manager::render_ui() const } ++mStrata.uiRedrawCount; - } + } end(); } } @@ -895,11 +895,11 @@ void manager::render_ui() const void manager::render_quad(const quad& mQuad) const { pImpl_->render_quad(mQuad); -} +} -void manager::render_quads(const quad& mQuad, const std::vector>& lQuadList) const -{ - pImpl_->render_quads(mQuad, lQuadList); +void manager::render_quads(const quad& mQuad, const std::vector>& lQuadList) const +{ + pImpl_->render_quads(mQuad, lQuadList); } void manager::create_strata_render_target(frame_strata mframe_strata) @@ -1146,7 +1146,6 @@ void manager::update(float fDelta) begin(pRenderTarget_); pRenderTarget_->clear(color::EMPTY); - std::map::const_iterator iterStrata; foreach (iterStrata, lStrataList_) { if (iterStrata->second.pSprite) @@ -1156,11 +1155,11 @@ void manager::update(float fDelta) end(); } } - + if (bBuildStrataList_ || bObjectMoved_ || (pInputManager_->get_mouse_raw_dx() != 0.0f) || - (pInputManager_->get_mouse_raw_dy() != 0.0f)) - bUpdateOveredFrame_ = true; + (pInputManager_->get_mouse_raw_dy() != 0.0f)) + bUpdateOveredFrame_ = true; if (bUpdateOveredFrame_ && bInputEnabled_) { @@ -1194,10 +1193,10 @@ void manager::update(float fDelta) } } } - - set_overed_frame_(pOveredFrame, iX, iY); - - bUpdateOveredFrame_ = false; + + set_overed_frame_(pOveredFrame, iX, iY); + + bUpdateOveredFrame_ = false; } bObjectMoved_ = false; @@ -1210,11 +1209,11 @@ void manager::update(float fDelta) bFirstIteration_ = false; } - ++uiFrameNumber_; + ++uiFrameNumber_; pEventManager_->frame_ended(); -} - -void manager::set_overed_frame_(frame* pFrame, int iX, int iY) +} + +void manager::set_overed_frame_(frame* pFrame, int iX, int iY) { if (pFrame && !pFrame->is_world_input_allowed()) pInputManager_->block_input("WORLD"); @@ -1230,7 +1229,7 @@ void manager::set_overed_frame_(frame* pFrame, int iX, int iY) } if (pOveredFrame_) - pOveredFrame_->notify_mouse_in_frame(true, iX, iY); + pOveredFrame_->notify_mouse_in_frame(true, iX, iY); } void manager::start_moving(uiobject* pObj, anchor* pAnchor, constraint mConstraint, std::function pApplyConstraintFunc) @@ -1379,9 +1378,9 @@ void manager::notify_object_moved() } void manager::fire_redraw(frame_strata mStrata) const -{ - std::map::const_iterator iter = lStrataList_.find(mStrata); - if (iter != lStrataList_.end()) +{ + std::map::const_iterator iter = lStrataList_.find(mStrata); + if (iter != lStrataList_.end()) iter->second.bRedraw = true; } @@ -1406,37 +1405,37 @@ void manager::enable_caching(bool bEnable) bool manager::is_caching_enabled() const { return bEnableCaching_; -} - -void manager::enable_input(bool bEnable) -{ - if (bInputEnabled_ != bEnable) - toggle_input(); -} - -void manager::toggle_input() -{ - bInputEnabled_ = !bInputEnabled_; - - if (bInputEnabled_) - { - bUpdateOveredFrame_ = true; +} + +void manager::enable_input(bool bEnable) +{ + if (bInputEnabled_ != bEnable) + toggle_input(); +} + +void manager::toggle_input() +{ + bInputEnabled_ = !bInputEnabled_; + + if (bInputEnabled_) + { + bUpdateOveredFrame_ = true; if (pFocusedFrame_) - pInputManager_->set_focus(true, pFocusedFrame_); - } - else - { - set_overed_frame_(nullptr); + pInputManager_->set_focus(true, pFocusedFrame_); + } + else + { + set_overed_frame_(nullptr); if (pFocusedFrame_) - pInputManager_->set_focus(false); - } -} - -bool manager::is_input_enabled() const -{ - return bInputEnabled_; + pInputManager_->set_focus(false); + } +} + +bool manager::is_input_enabled() const +{ + return bInputEnabled_; } void manager::clear_fonts_on_close(bool bClear) @@ -1687,8 +1686,8 @@ void manager::print_statistics() } std::string manager::print_ui() const -{ - std::stringstream s; +{ + std::stringstream s; if (lAddOnList_.size() >= 1) { @@ -1722,8 +1721,8 @@ std::string manager::print_ui() const if (iterObj->second->is_virtual() && !iterObj->second->get_parent()) s << iterObj->second->serialize("") << "\n########################\n" << std::endl; } - } - + } + return s.str(); } @@ -1735,11 +1734,11 @@ utils::wptr manager::get_event_manager() utils::wptr manager::get_input_manager() { return pInputManager_; -} - -const std::string& manager::get_locale() const -{ - return sLocale_; +} + +const std::string& manager::get_locale() const +{ + return sLocale_; } manager_impl::manager_impl() @@ -1765,10 +1764,10 @@ utils::refptr manager_impl::create_sprite(utils::refptr pMat, { return nullptr; } - -void manager_impl::set_parent(manager* pParent) -{ - pParent_ = pParent; + +void manager_impl::set_parent(manager* pParent) +{ + pParent_ = pParent; } strata::strata() : uiID(uint(-1)), bRedraw(true), uiRedrawCount(0u) diff --git a/gui/src/gui_manager_parser.cpp b/gui/src/gui_manager_parser.cpp index 1099c08c2a..a117a4aca6 100644 --- a/gui/src/gui_manager_parser.cpp +++ b/gui/src/gui_manager_parser.cpp @@ -21,9 +21,9 @@ void manager::parse_xml_file_(const std::string& sFile, addon* pAddOn) { if (pElemBlock->get_name() == "Script") { - std::string sFile = pAddOn->sDirectory + "/" + pElemBlock->get_attribute("file"); + std::string sScriptFile = pAddOn->sDirectory + "/" + pElemBlock->get_attribute("file"); - try { pLua_->do_file(sFile); } + try { pLua_->do_file(sScriptFile); } catch (lua::exception& e) { std::string sError = e.get_description(); diff --git a/gui/src/gui_slider_glues.cpp b/gui/src/gui_slider_glues.cpp index 8f08c61741..a33625678a 100644 --- a/gui/src/gui_slider_glues.cpp +++ b/gui/src/gui_slider_glues.cpp @@ -76,8 +76,8 @@ int lua_slider::_get_orientation(lua_State* pLua) switch (pSliderParent_->get_orientation()) { - case slider::ORIENT_VERTICAL : mFunc.push(std::string("VERTICAL")); - case slider::ORIENT_HORIZONTAL : mFunc.push(std::string("HORIZONTAL")); + case slider::ORIENT_VERTICAL : mFunc.push(std::string("VERTICAL")); break; + case slider::ORIENT_HORIZONTAL : mFunc.push(std::string("HORIZONTAL")); break; } return mFunc.on_return(); diff --git a/gui/src/gui_statusbar_glues.cpp b/gui/src/gui_statusbar_glues.cpp index 32a629d50b..bb5fa7e589 100644 --- a/gui/src/gui_statusbar_glues.cpp +++ b/gui/src/gui_statusbar_glues.cpp @@ -12,7 +12,7 @@ void status_bar::register_glue(utils::wptr pLua) } lua_status_bar::lua_status_bar(lua_State* pLua) : lua_frame(pLua) -{ +{ pStatusBarParent_ = dynamic_cast(pParent_); if (pParent_ && !pStatusBarParent_) throw exception("lua_status_bar", "Dynamic cast failed !"); @@ -40,8 +40,8 @@ int lua_status_bar::_get_orientation(lua_State* pLua) switch (pStatusBarParent_->get_orientation()) { - case status_bar::ORIENT_HORIZONTAL : mFunc.push(std::string("HORIZONTAL")); - case status_bar::ORIENT_VERTICAL : mFunc.push(std::string("VERTICAL")); + case status_bar::ORIENT_HORIZONTAL : mFunc.push(std::string("HORIZONTAL")); break; + case status_bar::ORIENT_VERTICAL : mFunc.push(std::string("VERTICAL")); break; } return mFunc.on_return(); diff --git a/gui/test/CMakeLists.txt b/gui/test/CMakeLists.txt index 0cb191a54c..b005fd2bc5 100644 --- a/gui/test/CMakeLists.txt +++ b/gui/test/CMakeLists.txt @@ -1,10 +1,5 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/gui/test) -include_directories(${PROJECT_SOURCE_DIR}/gui/impl/input/sfml/include) -include_directories(${PROJECT_SOURCE_DIR}/gui/impl/gui/gl/include) -include_directories(${PROJECT_SOURCE_DIR}/gui/include) -include_directories(${PROJECT_SOURCE_DIR}/luapp/include) -include_directories(${PROJECT_SOURCE_DIR}/xml/include) -include_directories(${PROJECT_SOURCE_DIR}/utils/include) +include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(${SFML_INCLUDE_DIR}) include_directories(${LUA_INCLUDE_DIR}) include_directories(${FREETYPE_INCLUDE_DIRS}) diff --git a/include/lxgui/gui_frame.hpp b/include/lxgui/gui_frame.hpp index b593a8680f..e88120b20b 100644 --- a/include/lxgui/gui_frame.hpp +++ b/include/lxgui/gui_frame.hpp @@ -495,8 +495,7 @@ namespace gui void set_min_resize(uint uiMinWidth, uint uiMinHeight); /// Sets this frame's minimum size. - /** \param uiMinWidth The minimum width this frame can have - * \param uiMinHeight The minimum height this frame can have + /** \param mMin Minimum dimensions of this frame */ void set_min_resize(const vector2ui& mMin); diff --git a/include/lxgui/gui_sprite.hpp b/include/lxgui/gui_sprite.hpp index 9233d4e10c..df516ef051 100644 --- a/include/lxgui/gui_sprite.hpp +++ b/include/lxgui/gui_sprite.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include "lxgui/gui_vector2.hpp" @@ -128,19 +128,19 @@ namespace gui /** \note This function is here for performance, when you want to set the * internal quad once and for all. */ - virtual void render_static() const; - - /// Renders a set of quads using this sprite's material. - /** \param lQuadsArray The set of quads you want to render. - * \note It is always much more efficient to use this method - * rather than calling render_XXX() repeatedly, as it - * allows for batch count reduction. The actual improvement - * depends on implementation. - */ + virtual void render_static() const; + + /// Renders a set of quads using this sprite's material. + /** \param lQuadsArray The set of quads you want to render. + * \note It is always much more efficient to use this method + * rather than calling render_XXX() repeatedly, as it + * allows for batch count reduction. The actual improvement + * depends on implementation. + */ virtual void render_quads(const std::vector>& lQuadsArray) const; /// Sets this sprite's internal quad. - /** \param lVertexArray + /** \param lVertexArray The new quad * \note This quad will be overwritten by any render_XXX() call. * If you want to render it, call render_static(). */ diff --git a/include/lxgui/input.hpp b/include/lxgui/input.hpp index 12ac5bc4c0..e57fc93409 100644 --- a/include/lxgui/input.hpp +++ b/include/lxgui/input.hpp @@ -22,52 +22,52 @@ namespace gui namespace input { - /// The base class for input implementation - class handler_impl - { + /// The base class for input implementation + class handler_impl + { public : /// Constructor. handler_impl(); /// Destructor. - virtual ~handler_impl() {} - - /// Updates this implementation handler. - virtual void update() = 0; - - /// Toggles mouse grab. - /** When the mouse is grabbed, it is confined to the borders - * of the main window. The actual cursor behavior when reaching - * those borders is of no importance : what matters is that - * relative mouse movement is always aquired, i.e. the mouse is never - * blocked. - * The mouse is not grabbed by default. - */ - virtual void toggle_mouse_grab() = 0; - - /// Returns the name of the key as it appears on the keyboard. - /** \return The name of the key as it appears on the keyboard - */ - virtual std::string get_key_name(key::code mKey) const = 0; - - struct key_state - { - std::array lKeyState; + virtual ~handler_impl() {} + + /// Updates this implementation handler. + virtual void update() = 0; + + /// Toggles mouse grab. + /** When the mouse is grabbed, it is confined to the borders + * of the main window. The actual cursor behavior when reaching + * those borders is of no importance : what matters is that + * relative mouse movement is always aquired, i.e. the mouse is never + * blocked. + * The mouse is not grabbed by default. + */ + virtual void toggle_mouse_grab() = 0; + + /// Returns the name of the key as it appears on the keyboard. + /** \return The name of the key as it appears on the keyboard + */ + virtual std::string get_key_name(key::code mKey) const = 0; + + struct key_state + { + std::array lKeyState; } mKeyboard; - - struct mouse_state - { - std::array lButtonState; - float fAbsX, fAbsY, fDX, fDY; + + struct mouse_state + { + std::array lButtonState; + float fAbsX, fAbsY, fDX, fDY; float fRelX, fRelY, fRelDX, fRelDY; - float fRelWheel; - bool bHasDelta; - } mMouse; - - std::vector lChars; - std::vector lCharsCache_; - }; + float fRelWheel; + bool bHasDelta; + } mMouse; + + std::vector lChars; + std::vector lCharsCache_; + }; /// A reference to an input implementation /** \note In case you want to share the same handler for @@ -76,24 +76,24 @@ namespace input * handler yourself. Else, it will be updated * by each input::manager (and that may be something * you don't want to happen). - */ - class handler - { - public : + */ + class handler + { + public : - /// Default constructor (empty handler). - handler(); + /// Default constructor (empty handler). + handler(); /// Implementation constructor. /** \param pImpl A pointer to the implementation handler - */ - template - handler(utils::refptr pImpl) : bManuallyUpdated_(false), pImpl_(pImpl) { - } + */ + template + handler(utils::refptr pImpl) : bManuallyUpdated_(false), pImpl_(pImpl) { + } /// Updates this handler. /** \note This function calls pImpl->update(). - */ + */ void update(); /// Checks if this handler is manually updated. @@ -114,38 +114,38 @@ namespace input void set_manually_updated(bool bManuallyUpdated); /// Returns the keyboard state of this input handler. - const handler_impl::key_state& get_key_state() const; - - /// Returns the unicode characters that has been entered. - /** \return The unicode characters entered with the keyboard - */ - std::vector get_chars() const; - - /// Returns the name of the key as it appears on the keyboard. - /** \return The name of the key as it appears on the keyboard - */ + const handler_impl::key_state& get_key_state() const; + + /// Returns the unicode characters that has been entered. + /** \return The unicode characters entered with the keyboard + */ + std::vector get_chars() const; + + /// Returns the name of the key as it appears on the keyboard. + /** \return The name of the key as it appears on the keyboard + */ std::string get_key_name(key::code mKey) const; /// Returns the mouse state of this input handler. const handler_impl::mouse_state& get_mouse_state() const; /// Returns the implementation specific handler. - utils::wptr get_impl(); - - private : + utils::wptr get_impl(); + + private : - bool bManuallyUpdated_; - utils::refptr pImpl_; + bool bManuallyUpdated_; + utils::refptr pImpl_; }; /// Handles inputs (keyboard and mouse) class manager { - public : - - /// Initializes this manager with the proper input source. - /** \param mHandler The input source (from another library) - */ + public : + + /// Initializes this manager with the proper input source. + /** \param mHandler The input source (from another library) + */ explicit manager(const handler& mHandler); #ifndef NO_CPP11_DELETE_FUNCTION @@ -232,11 +232,11 @@ namespace input * \return 'true' if the key has been released * \note Happens just when the key is released. */ - bool key_is_released(key::code mKey, bool bForce = false) const; - - /// Returns the UTF8 (multibyte) character that has been entered. - /** \return The multibyte UTF8 character just entered with the keyboard - */ + bool key_is_released(key::code mKey, bool bForce = false) const; + + /// Returns the UTF8 (multibyte) character that has been entered. + /** \return The multibyte UTF8 character just entered with the keyboard + */ std::vector get_chars() const; /// Returns the name of the provided key, as it appears on your keyboard. @@ -443,7 +443,7 @@ namespace input std::string get_mouse_button_string(mouse::button mID) const; /// Sets the double click maximum time. - /** \param dDoubleClickTime + /** \param dDoubleClickTime Maximum amount of time between two clicks in a double click */ void set_doubleclick_time(double dDoubleClickTime); @@ -552,7 +552,7 @@ namespace input bool bCtrlPressed_; bool bShiftPressed_; bool bAltPressed_; - bool bKey_; + bool bKey_; std::vector lChars_; std::deque lDownStack_; @@ -585,8 +585,8 @@ namespace input std::string sMouseButton_; bool bLastDragged_; - double dTime_; - + double dTime_; + handler mHandler_; }; } diff --git a/include/lxgui/luapp_var.hpp b/include/lxgui/luapp_var.hpp index dbf209b31e..7b3e4a473e 100644 --- a/include/lxgui/luapp_var.hpp +++ b/include/lxgui/luapp_var.hpp @@ -60,13 +60,13 @@ public : template const T& get() const { - const value* pValue = dynamic_cast*>(pValue_.get()); + const value* pValue = dynamic_cast*>(pValue_.get()); if (pValue) - return pValue->mT_; + return pValue->mT_; throw lua::exception("var", - "Conversion from "+std::string(pValue ? "type \""+std::string(pValue_->get_type().name()) + "Conversion from "+std::string(pValue ? "type \""+std::string(pValue_->get_type().name()) +"\"" : "empty lua::var")+" to \""+typeid(T).name()+"\" failed." ); } @@ -134,13 +134,7 @@ private : { public : - #ifdef MSVC - // Note : Disable a false warning from Microsoft's Visual C++ : - // "the inline specifier cannot be used when a friend declaration - // refers to a specialization of a function template" - #pragma warning( disable : 4396 ) - #endif - friend const T& var::get<>() const; + friend var; value(const T& mT) : mT_(mT) {} diff --git a/luapp/src/luapp_function.cpp b/luapp/src/luapp_function.cpp index 8e4a306166..05a0679416 100644 --- a/luapp/src/luapp_function.cpp +++ b/luapp/src/luapp_function.cpp @@ -183,7 +183,6 @@ bool function::check(bool bPrintError) foreach (iterArgList, lArgListStack_) { std::string sArguments = "\n - ["+utils::to_string(iterArgList->lArg_.size())+"] : "; - std::map>::iterator iterArg; foreach (iterArg, iterArgList->lArg_) { if (iterArg != iterArgList->lArg_.begin()) @@ -257,67 +256,67 @@ const std::string& function::get_name() const void function::push(const var& vValue) { if (uiReturnCount_ == uiReturnNbr_) - ++uiReturnNbr_; + ++uiReturnNbr_; pLua_->push(vValue); ++uiReturnCount_; -}*/ +}*/ void function::push(const std::string& sValue) { if (uiReturnCount_ == uiReturnNbr_) - ++uiReturnNbr_; + ++uiReturnNbr_; pLua_->push_string(sValue); ++uiReturnCount_; -} +} void function::push(const double& dValue) { if (uiReturnCount_ == uiReturnNbr_) - ++uiReturnNbr_; + ++uiReturnNbr_; pLua_->push_number(dValue); ++uiReturnCount_; -} +} void function::push(float fValue) { if (uiReturnCount_ == uiReturnNbr_) - ++uiReturnNbr_; + ++uiReturnNbr_; pLua_->push_number(fValue); ++uiReturnCount_; -} +} void function::push(int iValue) { if (uiReturnCount_ == uiReturnNbr_) - ++uiReturnNbr_; + ++uiReturnNbr_; pLua_->push_number(iValue); ++uiReturnCount_; -} +} void function::push(uint uiValue) { if (uiReturnCount_ == uiReturnNbr_) - ++uiReturnNbr_; + ++uiReturnNbr_; pLua_->push_number(uiValue); ++uiReturnCount_; -} +} void function::push(bool bValue) { if (uiReturnCount_ == uiReturnNbr_) - ++uiReturnNbr_; + ++uiReturnNbr_; pLua_->push_bool(bValue); diff --git a/luapp/src/luapp_state.cpp b/luapp/src/luapp_state.cpp index 980755c274..e5df992195 100644 --- a/luapp/src/luapp_state.cpp +++ b/luapp/src/luapp_state.cpp @@ -33,12 +33,12 @@ void open_libs(lua_State* pLua_) } } -int l_treat_error(lua_State*); +int l_treat_error(lua_State*); void default_print_function(const std::string&); state::state() { - pErrorFunction_ = &l_treat_error; + pErrorFunction_ = &l_treat_error; pPrintFunction_ = &default_print_function; pLua_ = lua_open(); @@ -248,15 +248,15 @@ void state::do_file(const std::string& sFile) { if (lua_isstring(pLua_, -1)) { - std::string sError = lua_tostring(pLua_, -1); + std::string sError = lua_tostring(pLua_, -1); lua_pop(pLua_, 1); lua_remove(pLua_, uiFuncPos); - throw lua::exception(sError); - } - else + throw lua::exception(sError); + } + else { lua_remove(pLua_, uiFuncPos); - throw lua::exception("state", "Cannot load file : \""+sFile+"\""); + throw lua::exception("state", "Cannot load file : \""+sFile+"\""); } } @@ -290,17 +290,17 @@ void state::do_string(const std::string& sStr) uint uiFuncPos = get_top(); if (luaL_loadstring(pLua_, sStr.c_str()) != 0) - { + { if (lua_isstring(pLua_, -1)) { std::string sError = lua_tostring(pLua_, -1); lua_settop(pLua_, uiFuncPos-1); throw lua::exception(sError); - } - else + } + else { lua_settop(pLua_, uiFuncPos-1); - throw lua::exception("state", "Unhandled error."); + throw lua::exception("state", "Unhandled error."); } } @@ -326,23 +326,23 @@ void state::do_string(const std::string& sStr) void state::call_function(const std::string& sFunctionName) { lua_pushcfunction(pLua_, pErrorFunction_); - uint uiFuncPos = get_top(); - + uint uiFuncPos = get_top(); + get_global(sFunctionName); if (lua_isnil(pLua_, -1)) { lua_settop(pLua_, uiFuncPos-1); - throw lua::exception("state", "\""+sFunctionName+"\" doesn't exist."); - } + throw lua::exception("state", "\""+sFunctionName+"\" doesn't exist."); + } if (!lua_isfunction(pLua_, -1)) - { + { lua::exception mExcept("state", "\""+sFunctionName+"\" is not a function ("+ get_type_name(get_type())+" : "+get_value().to_string()+")." ); lua_settop(pLua_, uiFuncPos-1); - throw mExcept; + throw mExcept; } bool bObject = false; @@ -361,7 +361,7 @@ void state::call_function(const std::string& sFunctionName) else lua_pop(pLua_, 1); } - } + } int iError; if (bObject) @@ -390,22 +390,22 @@ void state::call_function(const std::string& sFunctionName) void state::call_function(const std::string& sFunctionName, const std::vector& lArgumentStack) { lua_pushcfunction(pLua_, pErrorFunction_); - uint uiFuncPos = get_top(); - + uint uiFuncPos = get_top(); + get_global(sFunctionName); if (lua_isnil(pLua_, -1)) { lua_settop(pLua_, uiFuncPos-1); - throw lua::exception("state", "\""+sFunctionName+"\" doesn't exist."); - } + throw lua::exception("state", "\""+sFunctionName+"\" doesn't exist."); + } if (lua_isfunction(pLua_, -1)) { lua_settop(pLua_, uiFuncPos-1); - throw lua::exception("state", "\""+sFunctionName+"\" is not a function ("+get_type_name(get_type())+" : "+get_value().to_string()+")"); - } - + throw lua::exception("state", "\""+sFunctionName+"\" is not a function ("+get_type_name(get_type())+" : "+get_value().to_string()+")"); + } + std::vector::const_iterator iterArg; foreach (iterArg, lArgumentStack) push(*iterArg); @@ -593,6 +593,9 @@ std::string state::serialize(const std::string& sTab, int iIndex) break; } + case TYPE_NONE : + case TYPE_FUNCTION : + case TYPE_THREAD : default : break; } @@ -699,8 +702,8 @@ void state::new_table() } bool state::next(int iIndex) -{ - int res = lua_next(pLua_, iIndex); +{ + int res = lua_next(pLua_, iIndex); return res != 0; } @@ -792,29 +795,29 @@ void state::get_global(const std::string& sName) lDecomposedName.push_back(*iter2); } - lua_getglobal(pLua_, lDecomposedName.front().c_str()); + lua_getglobal(pLua_, lDecomposedName.front().c_str()); if (lDecomposedName.size() > 1) { - if (lua_isnil(pLua_, -1)) - return; + if (lua_isnil(pLua_, -1)) + return; lDecomposedName.pop_front(); std::deque::iterator iterWords; foreach (iterWords, lDecomposedName) { - lua_getfield(pLua_, -1, iterWords->c_str()); - lua_remove(pLua_, -2); + lua_getfield(pLua_, -1, iterWords->c_str()); + lua_remove(pLua_, -2); if (lua_isnil(pLua_, -1)) - return; - - if (!lua_istable(pLua_, -1) && iterWords+1 != lDecomposedName.end()) - { - lua_pop(pLua_, 1); - lua_pushnil(pLua_); - return; + return; + + if (!lua_istable(pLua_, -1) && iterWords+1 != lDecomposedName.end()) + { + lua_pop(pLua_, 1); + lua_pushnil(pLua_); + return; } } } @@ -871,7 +874,7 @@ double state::get_global_double(const std::string& sName, bool bCritical, double { f = lua_tonumber(pLua_, -1); lua_pop(pLua_, 1); - } + } return f; } @@ -927,7 +930,7 @@ bool state::get_global_bool(const std::string& sName, bool bCritical, bool bDefa { b = (lua_toboolean(pLua_, -1) != 0); lua_pop(pLua_, 1); - } + } return b; } @@ -971,7 +974,7 @@ int state::get_field_int(const std::string& sName, bool bCritical, int iDefaultV { i = lua_tonumber(pLua_, -1); lua_pop(pLua_, 1); - } + } return i; } @@ -1001,7 +1004,7 @@ double state::get_field_double(const std::string& sName, bool bCritical, double { f = lua_tonumber(pLua_, -1); lua_pop(pLua_, 1); - } + } return f; } @@ -1061,7 +1064,7 @@ bool state::get_field_bool(const std::string& sName, bool bCritical, bool bDefau { b = (lua_toboolean(pLua_, -1) != 0); lua_pop(pLua_, 1); - } + } return b; } diff --git a/utils/src/utils_filesystem.cpp b/utils/src/utils_filesystem.cpp index 80b8a037ff..78c4e3ffa9 100644 --- a/utils/src/utils_filesystem.cpp +++ b/utils/src/utils_filesystem.cpp @@ -299,11 +299,12 @@ bool make_directory_(const std::string& sPath) bool make_directory(const std::string& sPath) { - std::string sTemp = utils::trim(sPath, " \t"); + std::string sTemp = sPath; + utils::trim(sTemp, " \t"); utils::replace(sTemp, "\\", "/"); std::vector lDirs = utils::cut(sTemp, "/"); sTemp = ""; - + // Add back the root directory or drive #ifdef LINUX if (!sTemp.empty() && sTemp[0] == '/') diff --git a/xml/src/xml_block.cpp b/xml/src/xml_block.cpp index 3ca3a70082..a2d3745d62 100644 --- a/xml/src/xml_block.cpp +++ b/xml/src/xml_block.cpp @@ -2,7 +2,7 @@ #include "lxgui/xml_document.hpp" #include -#include +#include namespace xml { @@ -14,14 +14,14 @@ attribute::attribute(const std::string& name, bool optional, const std::string& sName(name), sDefault(def), bOptional(optional), bFound(false), mType(type) { } - -predefined_block::predefined_block() : pBlock(nullptr), uiMin(0), uiMax(0), uiRadioGroup(-1) -{ -} - -predefined_block::predefined_block(block* block, uint min, uint max, uint radio_group) : - pBlock(block), uiMin(min), uiMax(max), uiRadioGroup(radio_group) -{ + +predefined_block::predefined_block() : pBlock(nullptr), uiMin(0), uiMax(0), uiRadioGroup(-1) +{ +} + +predefined_block::predefined_block(block* block, uint min, uint max, uint radio_group) : + pBlock(block), uiMin(min), uiMax(max), uiRadioGroup(radio_group) +{ } block::block() : uiMaxNumber_(0), uiMinNumber_(0), uiRadioGroup_(-1), bRadioChilds_(false), @@ -49,21 +49,21 @@ block::~block() void block::copy(block* pBlock) { if (pBlock) - { + { bRadioChilds_ = pBlock->bRadioChilds_; sValue_ = pBlock->sValue_; lRadioBlockList_ = pBlock->lRadioBlockList_; lAttributeList_ = pBlock->lAttributeList_; - lDefBlockList_ = pBlock->lDefBlockList_; + lDefBlockList_ = pBlock->lDefBlockList_; lPreDefBlockList_ = pBlock->lPreDefBlockList_; } } bool block::add(const attribute& mAttrib) { - lAttributeList_[mAttrib.sName] = mAttrib; + lAttributeList_[mAttrib.sName] = mAttrib; return true; } @@ -211,9 +211,9 @@ bool block::check_attributes(const std::string& sAttributes) << "Unknown attribute : \"" << sAttrName << "\"." << std::endl; pDoc_->out << "Listing available possibilities :" << std::endl; - std::map::iterator iterAttr; - foreach (iterAttr, lAttributeList_) - pDoc_->out << " " << iterAttr->first << std::endl; + std::map::iterator itmp; + foreach (itmp, lAttributeList_) + pDoc_->out << " " << itmp->first << std::endl; return false; } @@ -252,7 +252,7 @@ bool block::check_attributes(const std::string& sAttributes) } bool block::check_blocks() -{ +{ if (bRadioChilds_) { std::map::iterator iterDefBlock; @@ -335,7 +335,7 @@ bool block::check_blocks() return false; } } - } + } std::map::iterator iterDefBlock; foreach (iterDefBlock, lDefBlockList_) @@ -453,21 +453,21 @@ uint block::get_min_count() const uint block::get_max_count() const { return uiMaxNumber_; -} - -bool block::is_radio() const -{ - return uiRadioGroup_ != (uint)(-1); +} + +bool block::is_radio() const +{ + return uiRadioGroup_ != (uint)(-1); } uint block::get_radio_group() const { return uiRadioGroup_; -} - -bool block::has_radio_children() const -{ - return bRadioChilds_; +} + +bool block::has_radio_children() const +{ + return bRadioChilds_; } void block::set_radio_group_optional(uint uiGroup) @@ -482,21 +482,21 @@ void block::set_radio_group_optional(uint uiGroup) pDoc_->out << "# Warning # : " << sFile_ << ":" << uiLineNbr_ << " : " << sName_ << " : " << "Radio group " << uiGroup << " has already been flagged as optional. Ignoring." << std::endl; } -} - -uint block::get_def_child_number() const -{ - return lDefBlockList_.size() + lPreDefBlockList_.size(); -} - -uint block::get_child_number() const -{ - return lFoundBlockList_.size(); } -uint block::get_child_number(const std::string& sName) const -{ - return lFoundBlockList_.count(sName); +uint block::get_def_child_number() const +{ + return lDefBlockList_.size() + lPreDefBlockList_.size(); +} + +uint block::get_child_number() const +{ + return lFoundBlockList_.size(); +} + +uint block::get_child_number(const std::string& sName) const +{ + return lFoundBlockList_.count(sName); } block* block::first(const std::string& sName) @@ -532,7 +532,7 @@ block* block::first(const std::string& sName) } block* block::next() -{ +{ if (mCurrIter_ != mEndIter_) { ++mCurrIter_; @@ -582,10 +582,10 @@ block* block::get_block(const std::string& sName) return iter->second; else return nullptr; -} - +} + block* block::get_radio_block(uint uiGroup) -{ +{ if (bRadioChilds_) { std::map::iterator iter = lRadioBlockList_.find(uiGroup); @@ -597,7 +597,7 @@ block* block::get_radio_block(uint uiGroup) << " : No block in radio group " << uiGroup << "." << std::endl; return nullptr; } - } + } else { pDoc_->out << "# Warning # : " << sFile_ << ":" << uiLineNbr_ << ":" << sName_ @@ -637,9 +637,9 @@ block* block::create_block(const std::string& sName) { if (!bCreating_) { - std::map::iterator iter = lDefBlockList_.find(sName); + std::map::iterator iter = lDefBlockList_.find(sName); if (iter != lDefBlockList_.end()) - pNewBlock_ = new block(iter->second); + pNewBlock_ = new block(iter->second); else pNewBlock_ = new block(*pDoc_->get_predefined_block(sName)); @@ -661,18 +661,18 @@ void block::add_block() { if (bCreating_) { - found_block_iterator iterAdded; - // Store the new block - iterAdded = lFoundBlockList_.insert(std::make_pair(pNewBlock_->get_name(), pNewBlock_)); - // Position it on the global stack - lFoundBlockStack_.push_back(iterAdded); - // Position it on the sorted stack - lFoundBlockSortedStacks_[pNewBlock_->get_name()].push_back(iterAdded); + found_block_iterator iterAdded; + // Store the new block + iterAdded = lFoundBlockList_.insert(std::make_pair(pNewBlock_->get_name(), pNewBlock_)); + // Position it on the global stack + lFoundBlockStack_.push_back(iterAdded); + // Position it on the sorted stack + lFoundBlockSortedStacks_[pNewBlock_->get_name()].push_back(iterAdded); pNewBlock_ = nullptr; bCreating_ = false; } -} +} block* block::create_def_block(const std::string& sName, uint uiMinNbr, uint uiMaxNbr) { @@ -681,61 +681,61 @@ block* block::create_def_block(const std::string& sName, uint uiMinNbr, uint uiM pBlock->set_parent(this); pBlock->set_document(pDoc_); return pBlock; -} - -block* block::create_radio_def_block(const std::string& sName, uint uiRadioGroup) -{ - if (!has_block(sName)) - { +} + +block* block::create_radio_def_block(const std::string& sName, uint uiRadioGroup) +{ + if (!has_block(sName)) + { bRadioChilds_ = true; - lRadioBlockList_[uiRadioGroup] = nullptr; - lDefBlockList_[sName] = block(sName, 0, 1, pDoc_->get_current_file_name(), pDoc_->get_current_line_nbr(), uiRadioGroup); + lRadioBlockList_[uiRadioGroup] = nullptr; + lDefBlockList_[sName] = block(sName, 0, 1, pDoc_->get_current_file_name(), pDoc_->get_current_line_nbr(), uiRadioGroup); block* pBlock = &lDefBlockList_[sName]; pBlock->set_parent(this); pBlock->set_document(pDoc_); - return pBlock; - } - else - { + return pBlock; + } + else + { throw utils::exception( - pDoc_->get_current_file_name()+":"+utils::to_string(pDoc_->get_current_line_nbr())+" : "+sName_, - "There is already a \""+sName+"\" block defined." - ); - } -} - + pDoc_->get_current_file_name()+":"+utils::to_string(pDoc_->get_current_line_nbr())+" : "+sName_, + "There is already a \""+sName+"\" block defined." + ); + } +} + predefined_block* block::add_predefined_block(block* pBlock, uint uiMinNbr, uint uiMaxNbr) -{ - if (!has_block(pBlock->get_name())) +{ + if (!has_block(pBlock->get_name())) + { + lPreDefBlockList_[pBlock->get_name()] = predefined_block(pBlock, uiMinNbr, uiMaxNbr); + return &lPreDefBlockList_[pBlock->get_name()]; + } + else { - lPreDefBlockList_[pBlock->get_name()] = predefined_block(pBlock, uiMinNbr, uiMaxNbr); - return &lPreDefBlockList_[pBlock->get_name()]; - } - else - { throw utils::exception( - pDoc_->get_current_file_name()+":"+utils::to_string(pDoc_->get_current_line_nbr())+" : "+sName_, - "There is already a \""+pBlock->get_name()+"\" block defined." - ); + pDoc_->get_current_file_name()+":"+utils::to_string(pDoc_->get_current_line_nbr())+" : "+sName_, + "There is already a \""+pBlock->get_name()+"\" block defined." + ); } -} - +} + predefined_block* block::add_predefined_radio_block(block* pBlock, uint uiRadioGroup) -{ - if (!has_block(pBlock->get_name())) - { +{ + if (!has_block(pBlock->get_name())) + { bRadioChilds_ = true; lRadioBlockList_[uiRadioGroup] = nullptr; - lPreDefBlockList_[pBlock->get_name()] = predefined_block(pBlock, 0, 1, uiRadioGroup); - - return &lPreDefBlockList_[pBlock->get_name()]; - } - else - { + lPreDefBlockList_[pBlock->get_name()] = predefined_block(pBlock, 0, 1, uiRadioGroup); + + return &lPreDefBlockList_[pBlock->get_name()]; + } + else + { throw utils::exception( - pDoc_->get_current_file_name()+":"+utils::to_string(pDoc_->get_current_line_nbr())+" : "+sName_, - "There is already a \""+pBlock->get_name()+"\" block defined." - ); + pDoc_->get_current_file_name()+":"+utils::to_string(pDoc_->get_current_line_nbr())+" : "+sName_, + "There is already a \""+pBlock->get_name()+"\" block defined." + ); } } diff --git a/xml/src/xml_document.cpp b/xml/src/xml_document.cpp index 8e85fa2bef..5ccd6d0545 100644 --- a/xml/src/xml_document.cpp +++ b/xml/src/xml_document.cpp @@ -10,9 +10,9 @@ namespace xml { document::document(const std::string& sDefFileName, std::ostream& mOut) : - out(mOut.rdbuf()), sDefFileName_(sDefFileName), uiCurrentLineNbr_(0), - bValid_(true), pState_(nullptr), bSmartComment_(false), - uiSmartCommentCount_(0), bMultilineComment_(false), uiMultilineCommentCount_(0), + out(mOut.rdbuf()), sDefFileName_(sDefFileName), uiCurrentLineNbr_(0), + bValid_(true), pState_(nullptr), bSmartComment_(false), + uiSmartCommentCount_(0), bMultilineComment_(false), uiMultilineCommentCount_(0), bPreProcessor_(false), uiPreProcessorCount_(0), uiSkippedPreProcessorCount_(0) { mXMLState_.set_document(this); @@ -38,9 +38,9 @@ document::document(const std::string& sDefFileName, std::ostream& mOut) : } document::document(const std::string& sFileName, const std::string& sDefFileName, std::ostream& mOut) : - out(mOut.rdbuf()),sFileName_(sFileName), sDefFileName_(sDefFileName), uiCurrentLineNbr_(0), - bValid_(true), pState_(nullptr), bSmartComment_(false), uiSmartCommentCount_(0), - bMultilineComment_(false), uiMultilineCommentCount_(0), bPreProcessor_(false), + out(mOut.rdbuf()),sFileName_(sFileName), sDefFileName_(sDefFileName), uiCurrentLineNbr_(0), + bValid_(true), pState_(nullptr), bSmartComment_(false), uiSmartCommentCount_(0), + bMultilineComment_(false), uiMultilineCommentCount_(0), bPreProcessor_(false), uiPreProcessorCount_(0), uiSkippedPreProcessorCount_(0) { mXMLState_.set_document(this); @@ -124,7 +124,7 @@ void document::load_definition_() // Start parsing line by line while (!mFile.eof() && bValid_) { - getline(mFile, sTemp); + getline(mFile, sTemp); utils::replace(sTemp, "\r", ""); sLine += sTemp; ++uiCurrentLineNbr_; @@ -476,7 +476,7 @@ bool document::check(const std::string& sPreProcCommands) std::string sLine, sTemp; while (!mFile.eof() && bValid_) { - getline(mFile, sTemp); + getline(mFile, sTemp); utils::replace(sTemp, "\r", ""); sLine += sTemp + "\n"; ++uiCurrentLineNbr_; @@ -1018,7 +1018,7 @@ void document::def_state::read_single_tag(const std::string& sTagContent) { throw utils::exception(pDoc_->get_current_location(), "\""+sParent+"\" has not (yet?) been pre-defined and cannot be "+ - (bCopy ? std::string("copied.") : std::string("inherited.")) + std::string(bCopy ? "copied." : "inherited.") ); } } @@ -1186,7 +1186,7 @@ void document::def_state::read_opening_tag(const std::string& sTagContent) { throw utils::exception(pDoc_->get_current_location(), "\""+sParent+"\" has not (yet?) been pre-defined and cannot be "+ - (bCopy ? std::string("copied.") : std::string("inherited.")) + std::string(bCopy ? "copied." : "inherited.") ); } }