本文整理汇总了C++中rString::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ rString::begin方法的具体用法?C++ rString::begin怎么用?C++ rString::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rString
的用法示例。
在下文中一共展示了rString::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIPAndPortFromString
NETWORK_API void NetworkUtility::GetIPAndPortFromString( const rString& input, rString& outIP, unsigned short& outPort )
{
if ( input == "" )
return;
outIP = "";
outPort = INVALID_PORT;
size_t colonCount = std::count( input.begin(), input.end(), ':' );
if ( colonCount == 1 )
{
outIP = GetIPFromString( input );
size_t colonPosition = input.find( ':' );
rString portString = input.substr( colonPosition + 1 );
if ( StringUtility::IsDigitsOnly( portString ) )
{
outPort = GetPortFromString( portString );
}
}
else if ( StringUtility::IsDigitsOnly( input ) )
{
outPort = GetPortFromString( input );
}
else
{
outIP = GetIPFromString( input );
}
}
示例2: GetIPFromString
rString NetworkUtility::GetIPFromString( const rString& input )
{
if ( input.find_first_not_of( ".0123456789:" ) != std::string::npos ) // Check if DNS
{
return GetIPFromDNS( input );
}
size_t dotCount = std::count( input.begin(), input.end(), '.' );
if ( dotCount != DOTS_IN_IPv4ADDRESS )
return "";
unsigned int adressParts[4];
rString portString;
rString processString = input;
for ( int i = 0; i < 4; ++i )
{
size_t pos = processString.find_first_of( ".:" );
rString currentAdressPart = processString.substr( 0, pos );
try
{
adressParts[i] = static_cast<unsigned int>( std::stoul( currentAdressPart.c_str() ) );
}
catch ( ... )
{
return "";
}
if ( adressParts[i] >= 256 )
{
return "";
}
processString.erase( 0, pos + 1 );
}
rOStringStream iposs;
iposs << adressParts[0] << "." << adressParts[1] << "." << adressParts[2] << "." << adressParts[3];
return iposs.str();
}