本文整理汇总了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://"))
示例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;
}
示例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);
}
示例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
}
示例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);
}
}
示例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;
}
示例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
}
示例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
}
示例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);
}
示例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;
}