GTK: Remove the StringTokenizer class and move the functionality to tools.cpp
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@990 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
c2e60fb564
commit
c40af7cc74
|
@ -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
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "cheatlist.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include <gtkmm/stock.h>
|
||||
|
||||
#include "intl.h"
|
||||
#include "stringtokenizer.h"
|
||||
#include <vector>
|
||||
|
||||
namespace VBA
|
||||
|
@ -128,7 +128,7 @@ void CheatListDialog::vOnCheatAdd()
|
|||
std::vector<Glib::ustring> tokens;
|
||||
Glib::RefPtr<Gtk::TextBuffer> code_buffer = poDialog->vGetCode();
|
||||
|
||||
StringTokenizer::tokenize(code_buffer->get_text(), tokens);
|
||||
vTokenize(code_buffer->get_text(), tokens);
|
||||
|
||||
for (std::vector<Glib::ustring>::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<Glib::ustring>::iterator it = tokens.begin();
|
||||
it != tokens.end();
|
||||
|
|
|
@ -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<Glib::ustring>& 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
|
|
@ -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 <glibmm/ustring.h>
|
||||
#include <vector>
|
||||
|
||||
namespace VBA
|
||||
{
|
||||
|
||||
class StringTokenizer
|
||||
{
|
||||
public:
|
||||
static void tokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens);
|
||||
};
|
||||
|
||||
} // VBA namespace
|
||||
|
||||
#endif
|
|
@ -62,4 +62,24 @@ bool bHasSuffix(const Glib::ustring & _rsString,
|
|||
return false;
|
||||
}
|
||||
|
||||
void vTokenize(Glib::ustring source, std::vector<Glib::ustring>& 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
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define __VBA_TOOLS_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
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<Glib::ustring>& tokens);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue