Beispiel #1
0
bool IPEndPoint::parse(sal_in_z const char* addressAndPort)
{
	std::string str(addressAndPort);

	// Get position of colon
	size_t pos = str.find(":");

	if (pos != std::string::npos) {
		std::string strIP = str.substr(0, pos);
		if(!mAddress.parse(strIP.c_str()))
			return false;

		// Check existence of port number after colon
		if (str.length() > pos+1) {
			int port;
			if(str2Int(str.substr(pos+1).c_str(), port))
				setPort(uint16_t(port));
			else
				return false;
		}
	} else {
		return mAddress.parse(addressAndPort);
	}

	return true;
}
int main(int argc, char ** argv){
  char str[] = "345";
  int num = 0;

  str2Int(str, num);

  std::cout<<num<<std::endl;

  system("pause");
  return 0;
}
Beispiel #3
0
/*==============================================================================
Function Name:  GetInt
Summary      :  取得键值
Input        :
                @lpKey      键
                @lpSection  段
Output       :
Return value :  键值(-1表示失败)
==============================================================================*/
int CSPIniReadWrite::getInt(const String& lpSection, const String& lpKey, int nDefaultValue)
{
	SectionVecIt iPG = findSection(lpSection);
	if (iPG == getLastSection())
	{
		return nDefaultValue;
	}

	Key::iterator iKEY = (*iPG)->m_tKeys.find(lpKey);
	if (iKEY == (*iPG)->m_tKeys.end())
	{
		return nDefaultValue;
	}
	return str2Int(iKEY->second);
}