12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /* libsegl - Sebas Extended GL Library
- * Collection of Opengl/3D-Math helpers
- *
- * Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
- * http://www.seba-geek.de
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
- #include "extstring.h"
-
- namespace segl {
-
- int explode(std::string str, std::string delim, std::vector<std::string> *erg, bool clean) {
- erg->clear();
-
- int treffer=0;
- std::string tmp;
- unsigned int pos;
-
- while((pos = str.find(delim))!=std::string::npos) {
- tmp = str.substr(0, pos);
-
- if(!clean || tmp!="") {
- // tmp nicht leer, hinzufügen
- erg->push_back(tmp);
- treffer++;
- }
-
- str = str.substr(pos+1); // alten kram entfernen
- }
-
- if(str.length()>0) {
- treffer++;
- erg->push_back(str);
- }
-
- return treffer;
- }
-
- std::string trim(std::string t) {
- while(t.length() && isspace(t[0])) {
- t = t.substr(1);
- }
-
- while(t.length() && ( isspace(t[t.length()-1]) )) {
- t = t.substr(0, t.length()-2);
- }
- return t;
- }
-
- std::string basename(std::string str) {
- return str.substr( str.rfind("/"));
- }
-
- std::string rbasename(std::string str) {
- return str.substr(0, str.rfind("/")+1);
- }
-
- } // namespace segl
|