00001 //----------------------------------------------------------------------------------- 00002 // 00003 // Pro-Vocation Light Engine (PVLE) 00004 // Copyright (C) 2007-2009 Sukender, KinoX & Buzib 00005 // For more information, contact us : sukender@free.fr 00006 // 00007 // This program is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // For any use that is not compatible with the terms of the GNU 00013 // General Public License, please contact the authors for alternative 00014 // licensing options. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License along 00022 // with this program; if not, write to the Free Software Foundation, Inc., 00023 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00024 // 00025 //----------------------------------------------------------------------------------- 00026 00027 #include <PVLE/Util/String.h> 00028 00029 00030 bool lexical_less::operator()(const std::string & str1, const std::string & str2) const { 00031 char a, b; 00032 const char *p1=str1.c_str(), *p2=str2.c_str(); 00033 for(int i1=0, i2=0; *p1 && *p2; ++p1, ++p2, ++i1, ++i2) { 00034 // Ignore spaces and simple quotes 00035 a = *p1; 00036 for(; a==' ' || a=='\'' && a!=0; ++p1, ++i1) a = *p1; 00037 if (a==0) break; 00038 00039 b = *p2; 00040 for(; b==' ' || b=='\'' && b!=0; ++p2, ++i2) b = *p2; 00041 if (b==0) break; 00042 00043 // Ignore accents 00044 a = unspecial(a); 00045 b = unspecial(b); 00046 00047 // Ignore caps 00048 if(a>='A' && a<='Z') a += 'a'-'A'; 00049 if(b>='A' && b<='Z') b += 'a'-'A'; 00050 00051 if (a!=b) return a<b; 00052 } 00053 // End of string 00054 if (*p2) return true; // str2 is longer (so s1<s2) 00055 //if (*p1) return false; // str1 is longer (so s1>s2) 00056 return false; 00057 }