view src/gtk/tools.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line source
1 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
2 // Copyright (C) 1999-2003 Forgotten
3 // Copyright (C) 2004 Forgotten and the VBA development team
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2, or(at your option)
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #include "tools.h"
21 namespace VBA
22 {
24 std::string sCutSuffix(const std::string & _rsString,
25 const std::string & _rsSep)
26 {
27 return _rsString.substr(0, _rsString.find_last_of(_rsSep));
28 }
30 Glib::ustring sCutSuffix(const Glib::ustring & _rsString,
31 const Glib::ustring & _rsSep)
32 {
33 return _rsString.substr(0, _rsString.find_last_of(_rsSep));
34 }
36 bool bHasSuffix(const Glib::ustring & _rsString,
37 const Glib::ustring & _rsSuffix,
38 bool _bCaseSensitive)
39 {
40 if (_rsSuffix.size() > _rsString.size())
41 {
42 return false;
43 }
45 Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
47 if (_bCaseSensitive)
48 {
49 if (_rsSuffix == sEnd)
50 {
51 return true;
52 }
53 }
54 else
55 {
56 if (_rsSuffix.lowercase() == sEnd.lowercase())
57 {
58 return true;
59 }
60 }
62 return false;
63 }
65 } // namespace VBA