diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gtk/tools.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,65 @@
     1.4 +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
     1.5 +// Copyright (C) 1999-2003 Forgotten
     1.6 +// Copyright (C) 2004 Forgotten and the VBA development team
     1.7 +
     1.8 +// This program is free software; you can redistribute it and/or modify
     1.9 +// it under the terms of the GNU General Public License as published by
    1.10 +// the Free Software Foundation; either version 2, or(at your option)
    1.11 +// any later version.
    1.12 +//
    1.13 +// This program is distributed in the hope that it will be useful,
    1.14 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 +// GNU General Public License for more details.
    1.17 +//
    1.18 +// You should have received a copy of the GNU General Public License
    1.19 +// along with this program; if not, write to the Free Software Foundation,
    1.20 +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    1.21 +
    1.22 +#include "tools.h"
    1.23 +
    1.24 +namespace VBA
    1.25 +{
    1.26 +
    1.27 +std::string sCutSuffix(const std::string & _rsString,
    1.28 +                       const std::string & _rsSep)
    1.29 +{
    1.30 +  return _rsString.substr(0, _rsString.find_last_of(_rsSep));
    1.31 +}
    1.32 +
    1.33 +Glib::ustring sCutSuffix(const Glib::ustring & _rsString,
    1.34 +                         const Glib::ustring & _rsSep)
    1.35 +{
    1.36 +  return _rsString.substr(0, _rsString.find_last_of(_rsSep));
    1.37 +}
    1.38 +
    1.39 +bool bHasSuffix(const Glib::ustring & _rsString,
    1.40 +                const Glib::ustring & _rsSuffix,
    1.41 +                bool _bCaseSensitive)
    1.42 +{
    1.43 +  if (_rsSuffix.size() > _rsString.size())
    1.44 +  {
    1.45 +    return false;
    1.46 +  }
    1.47 +
    1.48 +  Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
    1.49 +
    1.50 +  if (_bCaseSensitive)
    1.51 +  {
    1.52 +    if (_rsSuffix == sEnd)
    1.53 +    {
    1.54 +      return true;
    1.55 +    }
    1.56 +  }
    1.57 +  else
    1.58 +  {
    1.59 +    if (_rsSuffix.lowercase() == sEnd.lowercase())
    1.60 +    {
    1.61 +      return true;
    1.62 +    }
    1.63 +  }
    1.64 +
    1.65 +  return false;
    1.66 +}
    1.67 +
    1.68 +} // namespace VBA