mystring.cpp

来自「查看局域网的信息,类似网上邻居的功能,例如查看哪台计算机在线等」· C++ 代码 · 共 52 行

CPP
52
字号
#include "mystring.h"#include "getdebug.h"//this one is taken from Qt/QCStringMyString 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 qcstringint 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;};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?