diff --git a/source/graphics/TerrainProperties.cpp b/source/graphics/TerrainProperties.cpp index 2d5a743e99..e3619aad43 100644 --- a/source/graphics/TerrainProperties.cpp +++ b/source/graphics/TerrainProperties.cpp @@ -16,7 +16,6 @@ #include "ps/CLogger.h" #define LOG_CATEGORY "graphics" -using namespace std; CTerrainProperties::CTerrainProperties(CTerrainPropertiesPtr parent): m_pParent(parent), @@ -246,7 +245,7 @@ u32 CTerrainProperties::GetBaseColor() const STerrainPassability &CTerrainProperties::GetPassability(HEntity entity) { - vector::iterator it=m_Passabilities.begin(); + std::vector::iterator it=m_Passabilities.begin(); for (;it != m_Passabilities.end();++it) { if (entity->m_classes.IsMember(it->m_Type)) diff --git a/source/gui/CButton.cpp b/source/gui/CButton.cpp index 5c827bbaf7..5e1af5681d 100644 --- a/source/gui/CButton.cpp +++ b/source/gui/CButton.cpp @@ -8,7 +8,6 @@ CButton #include "lib/ogl.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor diff --git a/source/gui/CCheckBox.cpp b/source/gui/CCheckBox.cpp index 984a015554..8f5decc0a8 100644 --- a/source/gui/CCheckBox.cpp +++ b/source/gui/CCheckBox.cpp @@ -9,7 +9,6 @@ CCheckBox #include "ps/Font.h" #include "ps/CLogger.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor diff --git a/source/gui/CDropDown.cpp b/source/gui/CDropDown.cpp index 8c8b6aa1ab..b0c6aaafd4 100644 --- a/source/gui/CDropDown.cpp +++ b/source/gui/CDropDown.cpp @@ -9,7 +9,6 @@ CDropDown #include "lib/ogl.h" #include "lib/external_libraries/sdl.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor @@ -352,7 +351,7 @@ float CDropDown::GetBufferedZ() const { float bz = CList::GetBufferedZ(); if (m_Open) - return min(bz + 500.f, 1000.f); // TODO - don't use magic number for max z value + return std::min(bz + 500.f, 1000.f); // TODO - don't use magic number for max z value else return bz; } diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 9f96101b8a..5e82eb102c 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -42,8 +42,6 @@ CGUI #include "ps/Globals.h" #include "ps/Filesystem.h" -// namespaces used -using namespace std; const double SELECT_DBLCLICK_RATE = 0.5; #include "ps/CLogger.h" #define LOG_CATEGORY "gui" @@ -669,7 +667,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string, // (it doesn't count the line spacing) // Images on the left or the right side. - vector Images[2]; + std::vector Images[2]; int pos_last_img=-1; // Position in the string where last img (either left or right) were encountered. // in order to avoid duplicate processing. @@ -702,7 +700,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string, // Loop left/right for (int j=0; j<2; ++j) { - for (vector::const_iterator it = Feedback.m_Images[j].begin(); + for (std::vector::const_iterator it = Feedback.m_Images[j].begin(); it != Feedback.m_Images[j].end(); ++it) { @@ -763,7 +761,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string, // Loop through left and right side, from and to. for (int j=0; j<2; ++j) { - for (vector::const_iterator it = Images[j].begin(); + for (std::vector::const_iterator it = Images[j].begin(); it != Images[j].end(); ++it) { @@ -845,7 +843,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string, // x, that is what x_pointer is for. float x_pointer=0.f; - vector::iterator it; + std::vector::iterator it; for (it = Feedback2.m_TextCalls.begin(); it != Feedback2.m_TextCalls.end(); ++it) { it->m_Pos = CPos(x + x_pointer, y); @@ -954,7 +952,7 @@ void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor, CFont* font = NULL; CStr LastFontName; - for (vector::const_iterator it = Text.m_TextCalls.begin(); + for (std::vector::const_iterator it = Text.m_TextCalls.begin(); it != Text.m_TextCalls.end(); ++it) { @@ -987,7 +985,7 @@ void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor, if (font) delete font; - for (list::iterator it=Text.m_SpriteCalls.begin(); + for (std::list::iterator it=Text.m_SpriteCalls.begin(); it!=Text.m_SpriteCalls.end(); ++it) { @@ -1043,7 +1041,7 @@ void CGUI::ReportParseError(const char *str, ...) /** * @callgraph */ -void CGUI::LoadXmlFile(const string &Filename) +void CGUI::LoadXmlFile(const std::string &Filename) { // Reset parse error // we can later check if this has increased diff --git a/source/gui/CGUIScrollBarVertical.cpp b/source/gui/CGUIScrollBarVertical.cpp index 60a611463b..3e230bf058 100644 --- a/source/gui/CGUIScrollBarVertical.cpp +++ b/source/gui/CGUIScrollBarVertical.cpp @@ -8,7 +8,6 @@ IGUIScrollBar #include "ps/CLogger.h" #define LOG_CATEGORY "gui" -using namespace std; CGUIScrollBarVertical::CGUIScrollBarVertical() { @@ -149,7 +148,7 @@ CRect CGUIScrollBarVertical::GetBarRect() const } // Setup rectangle - ret.top = (from + (to-from)*(m_Pos/(max(1.f, m_ScrollRange - m_ScrollSpace)))); + ret.top = (from + (to-from)*(m_Pos/(std::max(1.f, m_ScrollRange - m_ScrollSpace)))); ret.bottom = ret.top+size; ret.right = m_X + ((m_RightAligned)?(0.f):(GetStyle()->m_Width)); ret.left = ret.right - GetStyle()->m_Width; diff --git a/source/gui/CImage.cpp b/source/gui/CImage.cpp index 86c70a450c..6fa5e8bfcd 100644 --- a/source/gui/CImage.cpp +++ b/source/gui/CImage.cpp @@ -8,7 +8,6 @@ CImage #include "lib/ogl.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor diff --git a/source/gui/CInput.cpp b/source/gui/CInput.cpp index 926dd99e7b..6b05dd9208 100644 --- a/source/gui/CInput.cpp +++ b/source/gui/CInput.cpp @@ -18,7 +18,6 @@ CInput #define LOG_CATEGORY "gui" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor @@ -304,7 +303,7 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev) m_iBufferPos_Tail = m_iBufferPos; } - list::iterator current = m_CharacterPositions.begin(); + std::list::iterator current = m_CharacterPositions.begin(); while (current != m_CharacterPositions.end()) { if (m_iBufferPos >= current->m_ListStart && @@ -352,7 +351,7 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev) m_iBufferPos_Tail = m_iBufferPos; } - list::iterator current = m_CharacterPositions.begin(); + std::list::iterator current = m_CharacterPositions.begin(); while (current != m_CharacterPositions.end()) { if (m_iBufferPos >= current->m_ListStart && @@ -780,7 +779,7 @@ void CInput::Draw() bool done = false; - for (list::const_iterator it = m_CharacterPositions.begin(); + for (std::list::const_iterator it = m_CharacterPositions.begin(); it != m_CharacterPositions.end(); ++it, buffered_y += ls, x_pointer = 0.f) { @@ -902,7 +901,7 @@ void CInput::Draw() bool using_selected_color = false; - for (list::const_iterator it = m_CharacterPositions.begin(); + for (std::list::const_iterator it = m_CharacterPositions.begin(); it != m_CharacterPositions.end(); ++it, buffered_y += ls) { @@ -1032,7 +1031,7 @@ void CInput::UpdateText(int from, int to_before, int to_after) CFont font(font_name); - list::iterator current_line; + std::list::iterator current_line; // used to replace the last updated copy, because it might contain a "space" // in the end, which shouldn't be there because of word-wrapping. the only @@ -1055,10 +1054,10 @@ void CInput::UpdateText(int from, int to_before, int to_after) { debug_assert(to_before != -1); - list::iterator destroy_row_from, destroy_row_to; + std::list::iterator destroy_row_from, destroy_row_to; // Used to check if the above has been set to anything, // previously a comparison like: - // destroy_row_from == list::iterator() + // destroy_row_from == std::list::iterator() // ... was used, but it didn't work with GCC. bool destroy_row_from_used=false, destroy_row_to_used=false; @@ -1067,7 +1066,7 @@ void CInput::UpdateText(int from, int to_before, int to_after) // to be redone. And when going along, we'll delete a row at a time // when continuing to see how much more after 'to' we need to remake. int i=0; - for (list::iterator it=m_CharacterPositions.begin(); + for (std::list::iterator it=m_CharacterPositions.begin(); it!=m_CharacterPositions.end(); ++it, ++i) { if (destroy_row_from_used == false && @@ -1153,7 +1152,7 @@ void CInput::UpdateText(int from, int to_before, int to_after) // in the coming erase. current_line = destroy_row_to; - list::iterator temp_it = destroy_row_to; + std::list::iterator temp_it = destroy_row_to; --temp_it; CStr c_caption1(caption.substr(destroy_row_from->m_ListStart, (temp_it->m_ListStart + temp_it->m_ListOfX.size()) -destroy_row_from->m_ListStart)); @@ -1167,7 +1166,7 @@ void CInput::UpdateText(int from, int to_before, int to_after) int delta = to_after - to_before; if (delta != 0) { - for (list::iterator it=current_line; + for (std::list::iterator it=current_line; it!=m_CharacterPositions.end(); ++it) { @@ -1266,10 +1265,10 @@ void CInput::UpdateText(int from, int to_before, int to_after) // check all rows and see if any existing if (row.m_ListStart != check_point_row_start) { - list::iterator destroy_row_from, destroy_row_to; + std::list::iterator destroy_row_from, destroy_row_to; // Are used to check if the above has been set to anything, // previously a comparison like: - // destroy_row_from == list::iterator() + // destroy_row_from == std::list::iterator() // was used, but it didn't work with GCC. bool destroy_row_from_used=false, destroy_row_to_used=false; @@ -1278,7 +1277,7 @@ void CInput::UpdateText(int from, int to_before, int to_after) // to be redone. And when going along, we'll delete a row at a time // when continuing to see how much more after 'to' we need to remake. int i=0; - for (list::iterator it=m_CharacterPositions.begin(); + for (std::list::iterator it=m_CharacterPositions.begin(); it!=m_CharacterPositions.end(); ++it, ++i) { if (destroy_row_from_used == false && @@ -1357,7 +1356,7 @@ void CInput::UpdateText(int from, int to_before, int to_after) copy_used = true; - list::iterator temp = destroy_row_to; + std::list::iterator temp = destroy_row_to; --temp; @@ -1406,7 +1405,7 @@ int CInput::GetMouseHoveringTextPosition() GUI::GetSetting(this, "buffer_zone", buffer_zone); GUI::GetSetting(this, "multiline", multiline); - list::iterator current = m_CharacterPositions.begin(); + std::list::iterator current = m_CharacterPositions.begin(); CPos mouse = GetMousePos(); @@ -1448,7 +1447,7 @@ int CInput::GetMouseHoveringTextPosition() if (row > (int)m_CharacterPositions.size()-1) row = (int)m_CharacterPositions.size()-1; - // TODO Gee (2004-11-21): Okay, I need a 'list' for some reasons, but I would really like to + // TODO Gee (2004-11-21): Okay, I need a 'std::list' for some reasons, but I would really like to // be able to get the specific element here. This is hopefully a temporary hack. for (int i=0; i::iterator ¤t, const float &x, float &wanted) +int CInput::GetXTextPosition(const std::list::iterator ¤t, const float &x, float &wanted) { int Ret=0; float previous=0.f; int i=0; - for (vector::iterator it=current->m_ListOfX.begin(); + for (std::vector::iterator it=current->m_ListOfX.begin(); it!=current->m_ListOfX.end(); ++it, ++i) { @@ -1581,10 +1580,10 @@ void CInput::UpdateAutoScroll() float spacing = (float)font.GetLineSpacing(); //float height = font.GetHeight(); - // TODO Gee (2004-11-21): Okay, I need a 'list' for some reasons, but I would really like to + // TODO Gee (2004-11-21): Okay, I need a 'std::list' for some reasons, but I would really like to // be able to get the specific element here. This is hopefully a temporary hack. - list::iterator current = m_CharacterPositions.begin(); + std::list::iterator current = m_CharacterPositions.begin(); int row=0; while (current != m_CharacterPositions.end()) { diff --git a/source/gui/CList.cpp b/source/gui/CList.cpp index 5ea0a67ffd..bf0a744c3b 100644 --- a/source/gui/CList.cpp +++ b/source/gui/CList.cpp @@ -9,7 +9,6 @@ CList #include "ps/CLogger.h" #include "lib/external_libraries/sdl.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor @@ -67,7 +66,7 @@ void CList::SetupText() // Delete all generated texts. Some could probably be saved, // but this is easier, and this function will never be called // continuously, or even often, so it'll probably be okay. - vector::iterator it; + std::vector::iterator it; for (it=m_GeneratedTexts.begin(); it!=m_GeneratedTexts.end(); ++it) { if (*it) diff --git a/source/gui/CProgressBar.cpp b/source/gui/CProgressBar.cpp index a08f504efc..d226445b5f 100644 --- a/source/gui/CProgressBar.cpp +++ b/source/gui/CProgressBar.cpp @@ -8,7 +8,6 @@ CProgressBar #include "lib/ogl.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor diff --git a/source/gui/CRadioButton.cpp b/source/gui/CRadioButton.cpp index bf7b273002..adb693a6a9 100644 --- a/source/gui/CRadioButton.cpp +++ b/source/gui/CRadioButton.cpp @@ -6,7 +6,6 @@ CCheckBox #include "GUI.h" #include "CRadioButton.h" -using namespace std; void CRadioButton::HandleMessage(const SGUIMessage &Message) { diff --git a/source/gui/CText.cpp b/source/gui/CText.cpp index 93343a1351..d8912e4bf7 100644 --- a/source/gui/CText.cpp +++ b/source/gui/CText.cpp @@ -8,7 +8,6 @@ CText #include "lib/ogl.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor diff --git a/source/gui/GUItext.cpp b/source/gui/GUItext.cpp index 36cdd1c971..c5d2db782f 100644 --- a/source/gui/GUItext.cpp +++ b/source/gui/GUItext.cpp @@ -13,7 +13,6 @@ GUI text #include "ps/Font.h" -using namespace std; static const wchar_t TagStart = '['; static const wchar_t TagEnd = ']'; @@ -40,7 +39,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, // Check out which text chunk this is within. //bool match_found = false; - vector::const_iterator itTextChunk; + std::vector::const_iterator itTextChunk; for (itTextChunk=m_TextChunks.begin(); itTextChunk!=m_TextChunks.end(); ++itTextChunk) { // - GL - Temp @@ -50,8 +49,8 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, // Get the area that is overlapped by both the TextChunk and // by the from/to inputted. int _from, _to; - _from = max(from, itTextChunk->m_From); - _to = min(to, itTextChunk->m_To); + _from = std::max(from, itTextChunk->m_From); + _to = std::min(to, itTextChunk->m_To); // If from is larger than to, than they are not overlapping if (_to == _from && itTextChunk->m_From == itTextChunk->m_To) @@ -74,7 +73,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, GetRawString()[to-1] == '\n') continue; } - // This string is just a break + // This std::string is just a break if (_from == from && from >= 1) { if (GetRawString()[from] == '\n' && @@ -132,7 +131,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, // append width, and make maximum height the height. Feedback.m_Size.cx += size.cx; - Feedback.m_Size.cy = max(Feedback.m_Size.cy, size.cy); + Feedback.m_Size.cy = std::max(Feedback.m_Size.cy, size.cy); // These are also needed later TextCall.m_Size = size; @@ -140,7 +139,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, // Now displace the sprite if the additional value in the tag // exists - if (itTextChunk->m_Tags[0].m_TagAdditionalValue != string()) + if (itTextChunk->m_Tags[0].m_TagAdditionalValue != std::string()) { CSize displacement; // Parse the value @@ -177,11 +176,11 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, TextCall.m_Font = DefaultFont; TextCall.m_UseCustomColor = false; - // Extract substring from RawString. + // Extract substd::string from RawString. TextCall.m_String = GetRawString().substr(_from, _to-_from); // Go through tags and apply changes. - vector::const_iterator it2; + std::vector::const_iterator it2; for (it2 = itTextChunk->m_Tags.begin(); it2 != itTextChunk->m_Tags.end(); ++it2) { if (it2->m_TagType == CGUIString::TextChunk::Tag::TAG_COLOR) @@ -189,7 +188,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, // Set custom color TextCall.m_UseCustomColor = true; - // Try parsing the color string + // Try parsing the color std::string if (!GUI::ParseString(it2->m_TagValue, TextCall.m_Color)) { if (pObject) @@ -219,7 +218,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, // Append width, and make maximum height the height. Feedback.m_Size.cx += size.cx; - Feedback.m_Size.cy = max(Feedback.m_Size.cy, size.cy); + Feedback.m_Size.cy = std::max(Feedback.m_Size.cy, size.cy); // These are also needed later TextCall.m_Size = size; @@ -304,8 +303,8 @@ void CGUIString::SetValue(const CStrW& str) Parser.InputTaskType("end", "/$ident"); long position = 0; - long from=0; // the position in the raw string where the last tag ended - long from_nonraw=0; // like from only in position of the REAL string, with tags. + long from=0; // the position in the raw std::string where the last tag ended + long from_nonraw=0; // like from only in position of the REAL std::string, with tags. long curpos = 0; // Current Text Chunk @@ -378,14 +377,14 @@ void CGUIString::SetValue(const CStrW& str) } else { - // Check for possible value-strings + // Check for possible value-std::strings if (Line.GetArgCount() >= 2) Line.GetArgString(1, tag.m_TagValue); // Check if an additional parameter was specified if (Line.GetArgCount() == 4) { - string str; + std::string str; Line.GetArgString(2, str); if (tag.m_TagType == TextChunk::Tag::TAG_ICON && @@ -431,7 +430,7 @@ void CGUIString::SetValue(const CStrW& str) { // Add that tag, but first, erase previous occurences of the // same tag. - vector::iterator it; + std::vector::iterator it; for (it = CurrentTextChunk.m_Tags.begin(); it != CurrentTextChunk.m_Tags.end(); ++it) { if (it->m_TagType == tag.m_TagType) @@ -473,7 +472,7 @@ void CGUIString::SetValue(const CStrW& str) // Search for the tag, if it's not added, then // pass it as plain text. - vector::iterator it; + std::vector::iterator it; for (it = CurrentTextChunk.m_Tags.begin(); it != CurrentTextChunk.m_Tags.end(); ++it) { if (it->m_TagType == tag.m_TagType) @@ -555,7 +554,7 @@ void CGUIString::SetValue(const CStrW& str) // Remove duplicates (only if larger than 2) if (m_Words.size() > 2) { - vector::iterator it; + std::vector::iterator it; int last_word = -1; for (it = m_Words.begin(); it != m_Words.end(); ) { diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp index a3faf4c5f6..5d8b64439d 100644 --- a/source/gui/GUIutil.cpp +++ b/source/gui/GUIutil.cpp @@ -9,7 +9,6 @@ GUI utilities extern int g_yres; -using namespace std; template <> bool __ParseString(const CStr& Value, bool &Output) @@ -45,7 +44,7 @@ bool __ParseString(const CStr& Value, CRect &Output) // Use the parser to parse the values CParser& parser (CParserCache::Get("_$value_$value_$value_$value_")); - string str = Value; + std::string str = Value; CParserLine line; line.ParseString(parser, str); @@ -111,7 +110,7 @@ bool __ParseString(const CStr& Value, CSize &Output) // Use the parser to parse the values CParser& parser (CParserCache::Get("_$value_$value_")); - string str = Value; + std::string str = Value; CParserLine line; line.ParseString(parser, str); diff --git a/source/gui/IGUIButtonBehavior.cpp b/source/gui/IGUIButtonBehavior.cpp index 7762d7fbb2..04d02fcc84 100644 --- a/source/gui/IGUIButtonBehavior.cpp +++ b/source/gui/IGUIButtonBehavior.cpp @@ -5,7 +5,6 @@ IGUIButtonBehavior #include "precompiled.h" #include "GUI.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp index c850a3e343..c9758cf58b 100644 --- a/source/gui/IGUIObject.cpp +++ b/source/gui/IGUIObject.cpp @@ -5,17 +5,13 @@ IGUIObject #include "precompiled.h" #include "GUI.h" -///// janwas: again, including etiquette? #include "ps/Parser.h" -///// - #include "gui/scripting/JSInterface_IGUIObject.h" #include "gui/scripting/JSInterface_GUITypes.h" extern int g_xres, g_yres; -using namespace std; //------------------------------------------------------------------- // Implementation Macros @@ -56,7 +52,7 @@ IGUIObject::IGUIObject() : IGUIObject::~IGUIObject() { { - map::iterator it; + std::map::iterator it; for (it = m_Settings.begin(); it != m_Settings.end(); ++it) { switch (it->second.m_Type) @@ -453,7 +449,7 @@ void IGUIObject::SetScriptHandler(const CStr& Action, JSObject* Function) void IGUIObject::ScriptEvent(const CStr& Action) { - map::iterator it = m_ScriptHandlers.find(Action); + std::map::iterator it = m_ScriptHandlers.find(Action); if (it == m_ScriptHandlers.end()) return; diff --git a/source/gui/IGUIScrollBar.cpp b/source/gui/IGUIScrollBar.cpp index 10a9adb636..115ed5945f 100644 --- a/source/gui/IGUIScrollBar.cpp +++ b/source/gui/IGUIScrollBar.cpp @@ -5,7 +5,6 @@ IGUIScrollBar #include "precompiled.h" #include "GUI.h" -using namespace std; //------------------------------------------------------------------- // IGUIScrollBar @@ -31,7 +30,7 @@ IGUIScrollBar::~IGUIScrollBar() void IGUIScrollBar::SetupBarSize() { - m_BarSize = min((float)m_ScrollSpace/(float)m_ScrollRange, 1.f); + m_BarSize = std::min((float)m_ScrollSpace/(float)m_ScrollRange, 1.f); } SGUIScrollBarStyle *IGUIScrollBar::GetStyle() const diff --git a/source/gui/IGUIScrollBarOwner.cpp b/source/gui/IGUIScrollBarOwner.cpp index 1426eb1c33..6b5d8ab712 100644 --- a/source/gui/IGUIScrollBarOwner.cpp +++ b/source/gui/IGUIScrollBarOwner.cpp @@ -5,7 +5,6 @@ IGUIScrollBarOwner #include "precompiled.h" #include "GUI.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor @@ -17,7 +16,7 @@ IGUIScrollBarOwner::IGUIScrollBarOwner() IGUIScrollBarOwner::~IGUIScrollBarOwner() { // Delete scroll-bars - vector::iterator it; + std::vector::iterator it; for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it) { delete *it; @@ -28,7 +27,7 @@ void IGUIScrollBarOwner::ResetStates() { IGUIObject::ResetStates(); - vector::iterator it; + std::vector::iterator it; for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it) { (*it)->SetBarPressed(false); @@ -61,7 +60,7 @@ SGUIScrollBarStyle * IGUIScrollBarOwner::GetScrollBarStyle(const CStr& style) co void IGUIScrollBarOwner::HandleMessage(const SGUIMessage &Message) { - vector::iterator it; + std::vector::iterator it; for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it) { (*it)->HandleMessage(Message); @@ -70,7 +69,7 @@ void IGUIScrollBarOwner::HandleMessage(const SGUIMessage &Message) void IGUIScrollBarOwner::Draw() { - vector::iterator it; + std::vector::iterator it; for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it) { (*it)->Draw(); diff --git a/source/gui/IGUITextOwner.cpp b/source/gui/IGUITextOwner.cpp index 47cc237f2f..a170a64162 100644 --- a/source/gui/IGUITextOwner.cpp +++ b/source/gui/IGUITextOwner.cpp @@ -5,7 +5,6 @@ IGUITextOwner #include "precompiled.h" #include "GUI.h" -using namespace std; //------------------------------------------------------------------- // Constructor / Destructor @@ -17,7 +16,7 @@ IGUITextOwner::IGUITextOwner() IGUITextOwner::~IGUITextOwner() { // Delete all generated texts. - vector::iterator it; + std::vector::iterator it; for (it=m_GeneratedTexts.begin(); it!=m_GeneratedTexts.end(); ++it) { delete *it; diff --git a/source/maths/Noise.cpp b/source/maths/Noise.cpp index c58f93bf0d..bb6c55897a 100644 --- a/source/maths/Noise.cpp +++ b/source/maths/Noise.cpp @@ -15,8 +15,6 @@ #include #include -using namespace std; - namespace { /// Random number generator (Boost Mersenne Twister) diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index 5ab17667f7..4c055ac98a 100644 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -9,9 +9,7 @@ #define LOG_CATEGORY "config" -using namespace std; - -typedef map TConfigMap; +typedef std::map TConfigMap; TConfigMap CConfigDB::m_Map[CFG_LAST]; CStr CConfigDB::m_ConfigFile[CFG_LAST]; bool CConfigDB::m_UseVFS[CFG_LAST]; @@ -284,8 +282,8 @@ bool CConfigDB::Reload(EConfigNamespace ns) // Send line to parser bool parseOk=parserLine.ParseString(parser, std::string(pos, lend)); // Get name and value from parser - string name; - string value; + std::string name; + std::string value; if (parseOk && parserLine.GetArgCount()>=2 && @@ -304,7 +302,7 @@ bool CConfigDB::Reload(EConfigNamespace ns) CConfigValue argument; argument.m_String = value; newMap[name].push_back( argument ); - LOG(CLogger::Normal, LOG_CATEGORY, "Loaded config string \"%s\" = \"%s\"", name.c_str(), value.c_str()); + LOG(CLogger::Normal, LOG_CATEGORY, "Loaded config std::string \"%s\" = \"%s\"", name.c_str(), value.c_str()); } } } diff --git a/source/ps/GameAttributes.cpp b/source/ps/GameAttributes.cpp index aecae8495a..57eb869363 100644 --- a/source/ps/GameAttributes.cpp +++ b/source/ps/GameAttributes.cpp @@ -10,7 +10,6 @@ #include "ps/XML/Xeromyces.h" #include "simulation/LOSManager.h" -using namespace std; CPlayerSlot::CPlayerSlot(size_t slotID, CPlayer *pPlayer): m_SlotID(slotID), @@ -282,7 +281,7 @@ void CGameAttributes::ScriptingInit() jsval_t CGameAttributes::JSI_GetOpenSlot(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv)) { - vector ::iterator it; + std::vector ::iterator it; for (it = m_PlayerSlots.begin();it != m_PlayerSlots.end();++it) { if ((*it)->GetAssignment() == SLOT_OPEN) @@ -353,10 +352,10 @@ CPlayerSlot *CGameAttributes::GetSlot(size_t index) void CGameAttributes::FinalizeSlots() { - // Back up our old slots, and empty the resulting vector - vector oldSlots; + // Back up our old slots, and empty the resulting std::vector + std::vector oldSlots; oldSlots.swap(m_PlayerSlots); - vector oldPlayers; + std::vector oldPlayers; oldPlayers.swap(m_Players); m_Players.push_back(oldPlayers[0]); // Gaia diff --git a/source/ps/Overlay.cpp b/source/ps/Overlay.cpp index 4bdbabc6e3..ffc5c5f9ef 100644 --- a/source/ps/Overlay.cpp +++ b/source/ps/Overlay.cpp @@ -9,14 +9,13 @@ Overlay.cpp #include "Overlay.h" #include "Parser.h" -using namespace std; bool CColor::ParseString(const CStr& Value, float DefaultAlpha) { // Use the parser to parse the values CParser& parser (CParserCache::Get("_[-$arg(_minus)]$value_[-$arg(_minus)]$value_[-$arg(_minus)]$value_[[-$arg(_minus)]$value_]")); - string str = Value; + std::string str = Value; CParserLine line; line.ParseString(parser, str); diff --git a/source/ps/Parser.cpp b/source/ps/Parser.cpp index 294ecf6bfb..4a2ff425b2 100644 --- a/source/ps/Parser.cpp +++ b/source/ps/Parser.cpp @@ -6,7 +6,6 @@ #pragma warning(disable:4786) #endif -using namespace std; //------------------------------------------------- // Macros @@ -80,7 +79,7 @@ CParserValue::~CParserValue() { } -// Parse the string in Value to different types +// Parse the std::string in Value to different types // bool bool CParserValue::GetBool(bool &ret) @@ -133,7 +132,7 @@ bool CParserValue::GetDouble(double &ret) // find decimal position DecimalPos = m_String.find("."); - if (DecimalPos == string::npos) + if (DecimalPos == std::string::npos) DecimalPos = Size; // Iterate left of the decimal sign @@ -184,7 +183,7 @@ bool CParserValue::GetDouble(double &ret) return true; } -// string - only return m_String, can't fail +// std::string - only return m_String, can't fail bool CParserValue::GetString(std::string &ret) { ret = m_String; @@ -285,7 +284,7 @@ bool CParserLine::ClearArguments() // Implementation of CParserFile::GetArg* // it just checks if argument isn't out of range, and // then it uses the the respective function in CParserValue -FUNC_IMPL_GETARG(GetArgString, GetString, string) +FUNC_IMPL_GETARG(GetArgString, GetString, std::string) FUNC_IMPL_GETARG(GetArgBool, GetBool, bool) FUNC_IMPL_GETARG(GetArgChar, GetChar, char) FUNC_IMPL_GETARG(GetArgShort, GetShort, short) @@ -308,8 +307,8 @@ FUNC_IMPL_GETARG(GetArgDouble, GetDouble, double) // TODO Gee: Make Parser use CStr. bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) { - // Don't process empty string - if (strLine == string()) + // Don't process empty std::string + if (strLine == std::string()) { m_ParseOK = false; // Empty lines should never be inputted by CParserFile return m_ParseOK; @@ -319,9 +318,9 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) bool Extract=false; size_t ExtractPos=0; char Buffer[256]; - char Letter[] = {'\0','\0'}; // Letter as string - vector Segments; - string strSub; + char Letter[] = {'\0','\0'}; // Letter as std::string + std::vector Segments; + std::string strSub; size_t i; // Set result to false, then if a match is found, turn it true @@ -332,11 +331,11 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) // Remove C++-styled comments! // * * * * int pos = strLine.find("//"); - if (pos != string::npos) + if (pos != std::string::npos) strLine = strLine.substr(0,pos); */ - // Divide string into smaller vectors, separators are unusual signs + // Divide std::string into smaller std::vectors, separators are unusual signs // * * * * for (i=0; i LastValidProgress; // When diving into a dynamic argument store store + std::vector LastValidProgress; // When diving into a dynamic argument store store // the last valid so you can go back to it - vector LastValidArgCount; // If an alternative route turns out to fail, we + std::vector LastValidArgCount; // If an alternative route turns out to fail, we // need to know the amount of arguments on the last // valid position, so we can remove them. - vector LastValidMatch; // Match at that point + std::vector LastValidMatch; // Match at that point bool BlockAltNode = false; // If this turns true, the alternative route // tested was not a success, and the settings // should be set back in order to test the @@ -459,7 +458,7 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) // the similarities. If enough // similarities are found, then we can declare progress as // that type and exit loop - vector::const_iterator cit_tt; + std::vector::const_iterator cit_tt; for (cit_tt = Parser.m_TaskTypes.begin(); cit_tt != Parser.m_TaskTypes.end(); ++cit_tt) @@ -634,7 +633,7 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) else { // Alright! An ident or const has been acquired, if we - // can't find any or if the string has run out + // can't find any or if the std::string has run out // that invalidates the match // String end? @@ -651,7 +650,7 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) switch(CurNode->m_Type) { case typeIdent: - // Check if this really is a string + // Check if this really is a std::string if (!_IsStrictNameChar(Segments[Progress][0])) { Match = false; @@ -672,7 +671,7 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) ++Progress; break; case typeValue: - // Check if this really is a string + // Check if this really is a std::string if (!_IsValueChar(Segments[Progress][0]) && Segments[Progress][0] != '\"') { @@ -694,10 +693,10 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine) ++Progress; break; case typeRest: - // Extract the whole of the string + // Extract the whole of the std::string // Reset, probably is but still - value.m_String = string(); + value.m_String = std::string(); for (i=Progress; i::iterator itTT; + std::vector::iterator itTT; for (itTT = m_TaskTypes.begin(); itTT != m_TaskTypes.end(); ++itTT) @@ -810,10 +809,10 @@ CParser::~CParser() // InputTaskType // ------------------------------------------------------------------| Function -// A task-type is a string representing the acquired syntax when parsing -// This function converts that string into a binary tree, making it easier +// A task-type is a std::string representing the acquired syntax when parsing +// This function converts that std::string into a binary tree, making it easier // and faster to later parse. -bool CParser::InputTaskType(const string& strName, const string& strSyntax) +bool CParser::InputTaskType(const std::string& strName, const std::string& strSyntax) { // Locals CParserTaskType TaskType; // Object we acquire to create @@ -832,7 +831,7 @@ bool CParser::InputTaskType(const string& strName, const string& strSyntax) // Working node CParserTaskTypeNode *CurNode = TaskType.m_BaseNode; - // Loop through the string and construct nodes in the binary tree + // Loop through the std::string and construct nodes in the binary tree // when applicable for (i=0; im_Letter = '\0'; - string str = string(Buffer); + std::string str = std::string(Buffer); // Check value and set up CurNode accordingly if (str == "value") CurNode->m_Type = typeValue; @@ -1012,7 +1011,7 @@ next [a] Null [a] <-- added NewNode else if (str == "arg") { - // After $arg, you need a parenthesis, within that parenthesis is a string + // After $arg, you need a parenthesis, within that parenthesis is a std::string // that will be added as an argument when it's passed through CurNode->m_Type = typeAddArg; @@ -1036,13 +1035,13 @@ next [a] Null [a] <-- added NewNode size_t Pos = strSyntax.find(")", ExtractPos+5); // Check if ')' exists at all - if (Pos == string::npos) + if (Pos == std::string::npos) { Error = true; break; } - // Now extract string within ( and ) + // Now extract std::string within ( and ) CurNode->m_String = strSyntax.substr(ExtractPos+4, Pos-(ExtractPos+4)); // Now update position diff --git a/source/sound/SoundGroup.h b/source/sound/SoundGroup.h index 616ecf6600..29bbe8cd8f 100644 --- a/source/sound/SoundGroup.h +++ b/source/sound/SoundGroup.h @@ -43,7 +43,6 @@ Example SoundGroup.xml #include "lib/res/sound/snd_mgr.h" #include -using namespace std; enum eSndGrpFlags { @@ -61,9 +60,9 @@ class CSoundGroup Handle m_hReplacement; - vector snd_group; // we store the handles so we can load now and play later - vector filenames; // we need the filenames so we can reload when necessary. - vector playtimes; // it would be better to store this in with the Handles perhaps? + std::vector snd_group; // we store the handles so we can load now and play later + std::vector filenames; // we need the filenames so we can reload when necessary. + std::vector playtimes; // it would be better to store this in with the Handles perhaps? CStr m_filepath; // the file path for the list of sound file resources CStr m_intensity_file; // the replacement aggregate 'intense' sound diff --git a/source/sound/SoundGroupMgr.cpp b/source/sound/SoundGroupMgr.cpp index d45d477325..eaba0379c2 100644 --- a/source/sound/SoundGroupMgr.cpp +++ b/source/sound/SoundGroupMgr.cpp @@ -27,6 +27,9 @@ #include "precompiled.h" #include "SoundGroupMgr.h" +typedef std::vector SoundGroups; +typedef SoundGroups::iterator SoundGroupIt; + CSoundGroupMgr *CSoundGroupMgr::m_pInstance = 0; @@ -48,8 +51,7 @@ void CSoundGroupMgr::DeleteInstance() { if(m_pInstance) { - - vector::iterator vIter = m_pInstance->m_Groups.begin(); + SoundGroupIt vIter = m_pInstance->m_Groups.begin(); while(vIter != m_pInstance->m_Groups.end()) vIter = m_pInstance->RemoveGroup(vIter); @@ -76,17 +78,14 @@ size_t CSoundGroupMgr::AddGroup(const char *XMLFile) /////////////////////////////////////////// // RemoveGroup() // in: size_t index into m_Groups -// out: vector::iterator - one past the index removed (sometimes useful) +// out: SoundGroupIt - one past the index removed (sometimes useful) // Removes and Releases a given soundgroup /////////////////////////////////////////// -vector::iterator CSoundGroupMgr::RemoveGroup(size_t index) +SoundGroupIt CSoundGroupMgr::RemoveGroup(size_t index) { - - vector::iterator vIter = m_Groups.begin(); + SoundGroupIt vIter = m_Groups.begin(); if(index >= m_Groups.size()) return vIter; - - CSoundGroup *temp = (*vIter); (*vIter)->ReleaseGroup(); @@ -100,11 +99,11 @@ vector::iterator CSoundGroupMgr::RemoveGroup(size_t index) /////////////////////////////////////////// // RemoveGroup() -// in: vector::iterator - item to remove -// out: vector::iterator - one past the index removed (sometimes useful) +// in: SoundGroupIt - item to remove +// out: SoundGroupIt - one past the index removed (sometimes useful) // Removes and Releases a given soundgroup /////////////////////////////////////////// -vector::iterator CSoundGroupMgr::RemoveGroup(vector::iterator iter) +SoundGroupIt CSoundGroupMgr::RemoveGroup(SoundGroupIt iter) { (*iter)->ReleaseGroup(); @@ -125,7 +124,7 @@ vector::iterator CSoundGroupMgr::RemoveGroup(vector::iterator vIter = m_Groups.begin(); + SoundGroupIt vIter = m_Groups.begin(); while(vIter != m_Groups.end()) { (*vIter)->Update(TimeSinceLastFrame); diff --git a/source/sound/SoundGroupMgr.h b/source/sound/SoundGroupMgr.h index 94f7ba78de..599ac5cc37 100644 --- a/source/sound/SoundGroupMgr.h +++ b/source/sound/SoundGroupMgr.h @@ -10,12 +10,11 @@ #include "SoundGroup.h" #include -using namespace std; class CSoundGroupMgr { public: - vector m_Groups; // a collection of sound groups + std::vector m_Groups; // a collection of sound groups static CSoundGroupMgr *m_pInstance; // our static instance of the manager static CSoundGroupMgr *GetInstance(); static void DeleteInstance(); @@ -44,18 +43,18 @@ public: /////////////////////////////////////////// // RemoveGroup() // in: size_t index into m_Groups - // out: vector::iterator - one past the index removed (sometimes useful) + // out: std::vector::iterator - one past the index removed (sometimes useful) // Removes and Releases a given soundgroup /////////////////////////////////////////// - vector::iterator RemoveGroup(size_t index); + std::vector::iterator RemoveGroup(size_t index); /////////////////////////////////////////// // RemoveGroup() - // in: vector::iterator - item to remove - // out: vector::iterator - one past the index removed (sometimes useful) + // in: std::vector::iterator - item to remove + // out: std::vector::iterator - one past the index removed (sometimes useful) // Removes and Releases a given soundgroup /////////////////////////////////////////// - vector::iterator RemoveGroup(vector::iterator iter); + std::vector::iterator RemoveGroup(std::vector::iterator iter); private: