当前位置: 首页>>代码示例>>C++>>正文


C++ MyString::length方法代码示例

本文整理汇总了C++中MyString::length方法的典型用法代码示例。如果您正苦于以下问题:C++ MyString::length方法的具体用法?C++ MyString::length怎么用?C++ MyString::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyString的用法示例。


在下文中一共展示了MyString::length方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: makeAbsolutePath

bool CDownload::makeAbsolutePath(const char* _myp, const char* _base,MyString& _dest)
{

	MyString p = _myp;
	MyString header5 = p.Left(5);
	MyString header17 = p.Left(17);
	MyString header8 = p.Left(8);
	MyString header7 = p.Left(7);

	bool	bAbsolute=  true;

	// OG 190110 Added \ for WinCE devices
	if ( ( p[0]=='\\') || ( p[0]=='/') || ( p[1]==':') || (!header5.CompareNoCase("http:")) )
		_dest = p; // absolute path
	else
		if (!header17.CompareNoCase("file://localhost/"))
		_dest = p.substr(17,p.length()-17); // absolute path for opera
	else
		if (!header8.CompareNoCase("file:///"))
#ifdef WIN32
		_dest = p.substr(8,p.length()-8); // absolute path
#else
	_dest = p.substr(7,p.length()-7); // keep the / on mac
#endif
	else
		if (!header7.CompareNoCase("file://"))
开发者ID:ogoguel,项目名称:activegs-ios,代码行数:26,代码来源:ActiveDownload.cpp

示例2: strcpy

const MyString MyString::operator=(MyString &right)
{
   if (len != 0)
      delete [] str;
   str = new char[right.length() + 1];
   strcpy(str, right.getValue());
   len = right.length();
   return *this;
}
开发者ID:akmartinez1,项目名称:CCSF,代码行数:9,代码来源:MyString.cpp

示例3:

void MyString::operator=(const MyString &other)
{
	if (max_size < other.length() + 1)
	{
		delete[] buffer;
		max_size = other.length() + 1;
		buffer = new char[max_size];
	}
	strcpy_s(buffer, max_size, other.buffer);
}
开发者ID:Jordior97,项目名称:MyZork,代码行数:10,代码来源:MyString.cpp

示例4: docker_add_env_walker

static bool docker_add_env_walker (void*pv, const MyString &var, const MyString &val) {
	ArgList* runArgs = (ArgList*)pv;
	MyString arg;
	arg.reserve_at_least(var.length() + val.length() + 2);
	arg = var;
	arg += "=";
	arg += val;
	runArgs->AppendArg("-e");
	runArgs->AppendArg(arg);
	return true; // true to keep iterating
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例5: length

void MyString::operator+=(const MyString &other)
{
	char *temp = nullptr;

	if (max_size < other.length() + length() + 1)
	{
		max_size = other.length() + length() + 1;
		temp = new char[max_size];
		strcpy_s(temp, max_size, buffer);
		delete[]buffer;
		strcat_s(temp, max_size, other.buffer);
		buffer = temp;
	}
	else
	{
		strcat_s(buffer, max_size, other.buffer);
	}
}
开发者ID:Jordior97,项目名称:MyZork,代码行数:18,代码来源:MyString.cpp

示例6: addr

std::vector<condor_sockaddr> resolve_hostname_raw(const MyString& hostname) {
	//
	// For now, we can just document that you need the Punycoded DSN name.
	// If somebody complains about that, we can revisit this.  (If we
	// assume/require UTF-8 (int the config file), we can still readily
	// distinguish Sinfuls, since ':' and '?' won't be used by the UTF-8
	// IDNs.)
	//
	std::vector<condor_sockaddr> ret;
	for( int i = 0; i < hostname.length(); ++i ) {
		if( isalnum( hostname[i] ) || hostname[i] == '-' ) { continue; }
		if( hostname[i] == '.' && i + 1 < hostname.length()
			&& hostname[i+1] != '.' ) { continue; }

		dprintf( D_HOSTNAME, "resolve_hostname_raw(): argument '%s' is not a valid DNS name, returning no addresses.\n", hostname.c_str() );
		return ret;
	}

	addrinfo_iterator ai;
	int res  = ipv6_getaddrinfo(hostname.Value(), NULL, ai);
	if (res) {
		dprintf(D_HOSTNAME, "ipv6_getaddrinfo() could not look up %s: %s (%d)\n", 
			hostname.Value(), gai_strerror(res), res);
		return ret;
	}

	// To eliminate duplicate address, here we use std::set.
	// we also want to maintain the order given by getaddrinfo.
	std::set<condor_sockaddr> s;
	while (addrinfo* info = ai.next()) {
		condor_sockaddr addr(info->ai_addr);
		if (s.find(addr) == s.end()) {
			ret.push_back(addr);
			s.insert(addr);
		}
	}
	return ret;
}
开发者ID:AlainRoy,项目名称:htcondor,代码行数:38,代码来源:ipv6_hostname.cpp

示例7:

// If they're at the same address they must be the same, as they're immutable objects
// If they consist of the same character array, they must also be the same
bool MyString::operator==(MyString& lhs_string){
    // Same address check
    if (this == &lhs_string){
        return true;
    }

    if (string_length != lhs_string.length()){
        return false;
    }


    for (int i = 0; i < string_length + 1; ++i){
        if (cstring[i] != lhs_string[i]){
            std::cout << cstring[i] << " Doesn't equal " << lhs_string[i] << std::endl;
            return false;
        }
    }

    return true; // All conditions are met, the string is the same
}
开发者ID:Compulsed,项目名称:MyString,代码行数:22,代码来源:my_string_library.cpp

示例8: onUrlRequested

void HTTPServer::onUrlRequested ( MyString req, SOCKET sock )
{
	if ( req.find ( ".." ) !=-1 ||
	     req.find ( "/.ht" ) !=-1 || req.endsWith ( "~" ) ) {
		// evil hacker trying to read non-wwwhome or secret file
		errorReport ( sock, "403", "Forbidden",
		              "You don't have permission to access the requested URL." );
	} else {
		MyString path = req;
		MyFile f ( path );
		if ( f.isDirectory() && !path.endsWith ( "/" ) ) {
			// redirect browser if referring to directory without final '/'
			path += "/";
		}

		if ( f.isDirectory() ) {
#if defined(FULLDEBUG) || defined(DEBUG)
			mLog ( "Is a directory: " + path );
#endif
			// if directory, implicitly add 'index.html'
			string header;
			header =  ( string ) "HTTP/1.1 200 OK\r\n"
			          + "Content-Type: text/html\r\n";

			string length = "Content-Length: ";

			string html_header = "<html><body>";
			// out all files here
			string files;
			getDirFiles ( path, &files );

			string html_footer = "</body></html>\r\n\r\n";
			string data = html_header + files + html_footer;


			//count content-length.
			stringstream sstm;
			sstm << data.length();
			length += sstm.str() + "\r\n\r\n";

			data = header + length + html_header + files + html_footer;

			int n = write ( sock, data.c_str(), data.length() +1 );
			if ( n < 0 ) {
				mLog ( "ERROR writing to socket" );
				exit ( 1 );
			}
#ifdef FULLDEBUG
			mLog ( "Wrote: " + data );
#endif

		} else {
			try {
				// send files

				MyString temp;
				temp = ( string ) "HTTP/1.0 200 OK\r\n";
				temp += 		"Content-Type: " + guessContentType ( path ) + "\r\n";


				string data;
				parseFile ( sock, path, &data ); // send raw file

				//count content-length.
				string length = "Content-Length: ";
				stringstream sstm;
				sstm << data.length();
				length += sstm.str() + "\r\n\r\n";

				temp += length + data;

				int n = write ( sock, temp.c_str(), temp.length() );
				if ( n < 0 ) {
					mLog ( "ERROR writing to socket" );
					exit ( 1 );
				}
#if defined(DEBUG) || defined(FULLDEBUG)
				mLog ( "200 OK" );
#endif
			} catch ( ... ) {
				// file not found
				errorReport ( sock, "404", "Not Found",
				              "The requested URL was not found on this server." );
			}//try-catch
		}//else

	}//else
}
开发者ID:vertexodessa,项目名称:CppWebServer,代码行数:88,代码来源:HttpServer.cpp

示例9: b

/*
 从MyString构造
 
 eg:
 MyString a;
 MyString b(a);
 */
MyString::MyString(const MyString& str)
{
    _str = new char[str.length() + 1];
    my_strcpy(_str, str._str);
}
开发者ID:SummerWish,项目名称:C_homework,代码行数:12,代码来源:MyString.cpp

示例10: setPassword

// Mutators
// Set password assumes two identical password strings
bool User::setPassword( const MyString& new1, const MyString& new2){
	if (new1.length()<6 || !new1.compare(new2)) return false;
	mPassword.changeTo(new1);	// change password
	return true;
}
开发者ID:hdthba,项目名称:the-teaching-machine-and-webwriter,代码行数:7,代码来源:user.cpp


注:本文中的MyString::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。