diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cfcf162..c66aaa43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,7 +260,6 @@ SET(SRC_GTK src/gtk/screenarea.cpp src/gtk/screenarea-cairo.cpp src/gtk/screenarea-opengl.cpp - src/gtk/stringtokenizer.cpp src/gtk/tools.cpp src/gtk/window.cpp src/sdl/inputSDL.cpp diff --git a/src/gtk/cheatlist.cpp b/src/gtk/cheatlist.cpp index acef25cd..ce1b7f0d 100644 --- a/src/gtk/cheatlist.cpp +++ b/src/gtk/cheatlist.cpp @@ -17,11 +17,11 @@ // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cheatlist.h" +#include "tools.h" #include #include "intl.h" -#include "stringtokenizer.h" #include namespace VBA @@ -128,7 +128,7 @@ void CheatListDialog::vOnCheatAdd() std::vector tokens; Glib::RefPtr code_buffer = poDialog->vGetCode(); - StringTokenizer::tokenize(code_buffer->get_text(), tokens); + vTokenize(code_buffer->get_text(), tokens); for (std::vector::iterator it = tokens.begin(); it != tokens.end(); @@ -152,7 +152,7 @@ void CheatListDialog::vOnCheatAdd() Glib::ustring sCode; Glib::ustring sPart = ""; - StringTokenizer::tokenize(code_buffer->get_text(), tokens); + vTokenize(code_buffer->get_text(), tokens); for (std::vector::iterator it = tokens.begin(); it != tokens.end(); diff --git a/src/gtk/stringtokenizer.cpp b/src/gtk/stringtokenizer.cpp deleted file mode 100644 index f64ce36b..00000000 --- a/src/gtk/stringtokenizer.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. -// Copyright (C) 1999-2003 Forgotten -// Copyright (C) 2004 Forgotten and the VBA development team - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or(at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "stringtokenizer.h" - -namespace VBA -{ - -void StringTokenizer::tokenize(Glib::ustring source, std::vector& tokens) -{ - Glib::ustring delimiters = " \t\n\r"; - - // Skip delimiters at beginning. - Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0); - // Find first "non-delimiter". - Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos); - - while (Glib::ustring::npos != pos || std:: string::npos != lastPos) - { - // Found a token, add it to the vector. - tokens.push_back(source.substr(lastPos, pos - lastPos)); - // Skip delimiters. Note the "not_of" - lastPos = source.find_first_not_of(delimiters, pos); - // Find next "non-delimiter" - pos = source.find_first_of(delimiters, lastPos); - } -} - -} // VBA namespace diff --git a/src/gtk/stringtokenizer.h b/src/gtk/stringtokenizer.h deleted file mode 100644 index 02380151..00000000 --- a/src/gtk/stringtokenizer.h +++ /dev/null @@ -1,37 +0,0 @@ -// -*- C++ -*- -// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. -// Copyright (C) 1999-2003 Forgotten -// Copyright (C) 2004 Forgotten and the VBA development team - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or(at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef __VBA_STRINGTOKENIZER_H__ -#define __VBA_STRINGTOKENIZER_H__ - -#include -#include - -namespace VBA -{ - -class StringTokenizer -{ -public: - static void tokenize(Glib::ustring source, std::vector& tokens); -}; - -} // VBA namespace - -#endif diff --git a/src/gtk/tools.cpp b/src/gtk/tools.cpp index 6e1a0650..b4aa4366 100644 --- a/src/gtk/tools.cpp +++ b/src/gtk/tools.cpp @@ -62,4 +62,24 @@ bool bHasSuffix(const Glib::ustring & _rsString, return false; } +void vTokenize(Glib::ustring source, std::vector& tokens) +{ + Glib::ustring delimiters = " \t\n\r"; + + // Skip delimiters at beginning. + Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0); + // Find first "non-delimiter". + Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos); + + while (Glib::ustring::npos != pos || std:: string::npos != lastPos) + { + // Found a token, add it to the vector. + tokens.push_back(source.substr(lastPos, pos - lastPos)); + // Skip delimiters. Note the "not_of" + lastPos = source.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = source.find_first_of(delimiters, lastPos); + } +} + } // namespace VBA diff --git a/src/gtk/tools.h b/src/gtk/tools.h index 6dca2288..842397a8 100644 --- a/src/gtk/tools.h +++ b/src/gtk/tools.h @@ -21,6 +21,7 @@ #define __VBA_TOOLS_H__ #include +#include #include namespace VBA @@ -35,6 +36,8 @@ Glib::ustring sCutSuffix(const Glib::ustring & _rsString, bool bHasSuffix(const Glib::ustring & _rsString, const Glib::ustring & _rsSuffix, bool _bCaseSensitive = true); + +void vTokenize(Glib::ustring source, std::vector& tokens); }