summaryrefslogtreecommitdiffstats
path: root/lanbrowsing/lisa/mystring.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /lanbrowsing/lisa/mystring.cpp
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lanbrowsing/lisa/mystring.cpp')
-rw-r--r--lanbrowsing/lisa/mystring.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/lanbrowsing/lisa/mystring.cpp b/lanbrowsing/lisa/mystring.cpp
new file mode 100644
index 00000000..2b7af2d2
--- /dev/null
+++ b/lanbrowsing/lisa/mystring.cpp
@@ -0,0 +1,52 @@
+#include "mystring.h"
+
+#include <ctype.h>
+
+//this one is taken from Qt/QCString
+
+MyString stripWhiteSpace(MyString str)
+{
+ if ( str.isEmpty() ) // nothing to do
+ return "";
+
+ char const *s = str.data();
+ MyString result = s;
+ int reslen = result.length();
+ if ( !isspace(s[0]) && !isspace(s[reslen-1]) )
+ return result; // returns a copy
+
+ s = result.data();
+ int start = 0;
+ int end = reslen - 1;
+ while ( isspace(s[start]) ) // skip white space from start
+ start++;
+ if ( s[start] == '\0' )
+ { // only white space
+ result.resize( 1 );
+ return "";
+ }
+
+ while ( end && isspace(s[end]) ) // skip white space from end
+ end--;
+
+ end -= start - 1;
+
+ result=str.mid(start,end);
+ //memmove( result.data(), &s[start], end );
+ //result.resize( end + 1 );
+ return result;
+}
+
+//mainly taken from qcstring
+int MyString::contains(char c)
+{
+ int count = 0;
+ char const *d = c_str();
+ if ( d==0 )
+ return 0;
+ while ( *d )
+ if ( *d++ == c )
+ count++;
+ return count;
+}
+