本文整理汇总了C++中StringSplit函数的典型用法代码示例。如果您正苦于以下问题:C++ StringSplit函数的具体用法?C++ StringSplit怎么用?C++ StringSplit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringSplit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StringSplit
void cFireworkItem::FadeColoursFromString(const AString & a_String, cFireworkItem & a_FireworkItem)
{
AStringVector Split = StringSplit(a_String, ";");
for (size_t itr = 0; itr < Split.size(); ++itr)
{
if (Split[itr].empty())
{
continue;
}
a_FireworkItem.m_FadeColours.push_back(atoi(Split[itr].c_str()));
}
}
示例2: get_config_path
std::string get_config_path()
{
//ex: C:\Users\Mark\Documents\Visual Studio
//2010\Projects\FirstCPPApplication\Debug\BiochRL++.exe
std::string exepath = get_exe_path();
std::vector<std::string> exesplit = StringSplit(exepath, kPathSeparator);
exesplit.pop_back();
std::string data = "config";
data+=kPathSeparator;
exesplit.push_back(data);
return StringJoin(exesplit, kPathSeparator, false);
};
示例3: GetFullCurrentElementName
void SkinXml::getInstanceNames()
{
string currentElement = GetFullCurrentElementName();
string strData = "";
vector<string> Settings;
StringSplit(currentElement, "--", &Settings);
unsigned int size = Settings.size()-1;
if (strcmp(Settings.at(size).c_str(), "Instance")==0)
{
Instance = m_Attributes["id"].c_str();
}
}
示例4: AddToMap
void AddToMap(const AString & a_Name, const AString & a_Value)
{
AStringVector Split = StringSplit(a_Value, ":");
if (Split.size() == 1)
{
Split = StringSplit(a_Value, "^");
}
if (Split.empty())
{
return;
}
short ItemType;
if (!StringToInteger(Split[0], ItemType))
{
ASSERT(!"Invalid item type");
}
short ItemDamage = -1;
if (Split.size() > 1 && !StringToInteger(Split[1], ItemDamage))
{
ASSERT(!"Invalid item damage");
}
m_Map[a_Name] = std::make_pair(ItemType, ItemDamage);
}
示例5: StringSplit
bool cPlayer::HasPermission(const AString & a_Permission)
{
if (a_Permission.empty())
{
// Empty permission request is always granted
return true;
}
AStringVector Split = StringSplit( a_Permission, "." );
PermissionMap Possibilities = m_ResolvedPermissions;
// Now search the namespaces
while( Possibilities.begin() != Possibilities.end() )
{
PermissionMap::iterator itr = Possibilities.begin();
if( itr->second )
{
AStringVector OtherSplit = StringSplit( itr->first, "." );
if( OtherSplit.size() <= Split.size() )
{
unsigned int i;
for( i = 0; i < OtherSplit.size(); ++i )
{
if( OtherSplit[i].compare( Split[i] ) != 0 )
{
if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard!
break;
}
}
if( i == Split.size() ) return true;
}
}
Possibilities.erase( itr );
}
// Nothing that matched :(
return false;
}
示例6: StringSplit
int CSBFSpot::getSunRiseSunSetMinutes(const bool bGetSunRise)
{
std::vector<std::string> strarray;
std::vector<std::string> sunRisearray;
std::vector<std::string> sunSetarray;
if (!m_mainworker.m_LastSunriseSet.empty())
{
StringSplit(m_mainworker.m_LastSunriseSet, ";", strarray);
StringSplit(strarray[0], ":", sunRisearray);
StringSplit(strarray[1], ":", sunSetarray);
int sunRiseInMinutes = (atoi(sunRisearray[0].c_str()) * 60) + atoi(sunRisearray[1].c_str());
int sunSetInMinutes = (atoi(sunSetarray[0].c_str()) * 60) + atoi(sunSetarray[1].c_str());
if (bGetSunRise) {
return sunRiseInMinutes;
}
else {
return sunSetInMinutes;
}
}
return 0;
}
示例7: GetNotifications
bool CNotificationHelper::CheckAndHandleNotification(
const uint64_t Idx,
const std::string &devicename,
const _eNotificationTypes ntype,
const std::string &message)
{
std::vector<_tNotification> notifications = GetNotifications(Idx);
if (notifications.size() == 0)
return false;
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT SwitchType, CustomImage FROM DeviceStatus WHERE (ID=%" PRIu64 ")", Idx);
if (result.size() == 0)
return false;
std::string szExtraData = "|Name=" + devicename + "|SwitchType=" + result[0][0] + "|CustomImage=" + result[0][1] + "|";
std::string notValue;
time_t atime = mytime(NULL);
//check if not sent 12 hours ago, and if applicable
atime -= m_NotificationSensorInterval;
std::string ltype = Notification_Type_Desc(ntype, 1);
std::vector<_tNotification>::const_iterator itt;
for (itt = notifications.begin(); itt != notifications.end(); ++itt)
{
if (itt->LastUpdate)
TouchLastUpdate(itt->ID);
std::vector<std::string> splitresults;
StringSplit(itt->Params, ";", splitresults);
if (splitresults.size() < 1)
continue; //impossible
std::string atype = splitresults[0];
if (atype == ltype)
{
if ((atime >= itt->LastSend) || (itt->SendAlways)) //emergency always goes true
{
std::string msg = message;
if (!itt->CustomMessage.empty())
msg = ParseCustomMessage(itt->CustomMessage, devicename, notValue);
SendMessageEx(Idx, devicename, itt->ActiveSystems, msg, msg, szExtraData, itt->Priority, std::string(""), true);
TouchNotification(itt->ID);
}
}
}
return true;
}
示例8: StrSplit
int StrSplit(const char *src, const char *delim, __gnu_cxx::StrSplitMap &map, int maxParts)
{
string workStr;
workStr = src;
return StringSplit(workStr, delim, map, maxParts);
#if 0
int entryCount = 0;
char *workStr;
char *tmpStr;
char *part;
if (!strlen(src)) return 0;
workStr = new char[strlen(src)+1024];
strcpy(workStr, src);
part = strsep(&workStr, delim);
while (part != NULL) {
if ((maxParts) && (entryCount >= maxParts)) {
// The user specified a maximum number of parts, append
// this entry to the previous part, and make sure we
// put the delimiter back in.
entryCount--;
char *tmpStr2 = new char[strlen(part) + strlen(delim) + strlen(map[entryCount].c_str()) + 16];
strcpy(tmpStr2, map[entryCount].c_str());
strcat(tmpStr2, delim);
strcat(tmpStr2, part);
map[entryCount] = tmpStr2;
part = strsep(&workStr, delim);
entryCount++;
} else {
tmpStr = new char[strlen(part)+16];
strcpy(tmpStr, part);
map[entryCount++] = tmpStr;
part = strsep(&workStr, delim);
}
}
return entryCount;
#endif
}
示例9: StringSplit
void CTCPClient::handleRead(const boost::system::error_code& e,
std::size_t bytes_transferred)
{
if (!e)
{
//do something with the data
//buffer_.data(), buffer_.data() + bytes_transferred
if (bytes_transferred>7)
{
std::string recstr;
recstr.append(buffer_.data(),bytes_transferred);
if (recstr.find("AUTH")!=std::string::npos)
{
//Authentication
std::vector<std::string> strarray;
StringSplit(recstr, ";", strarray);
if (strarray.size()==3)
{
m_bIsLoggedIn=pConnectionManager->HandleAuthentication(shared_from_this(), strarray[1] ,strarray[2]);
if (!m_bIsLoggedIn)
{
//Wrong username/password
pConnectionManager->stopClient(shared_from_this());
return;
}
m_username=strarray[1];
}
}
else
{
pConnectionManager->DoDecodeMessage(this,(const unsigned char *)buffer_.data());
}
}
//ready for next read
socket_->async_read_some(boost::asio::buffer(buffer_),
boost::bind(&CTCPClient::handleRead, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
else if (e != boost::asio::error::operation_aborted)
{
pConnectionManager->stopClient(shared_from_this());
}
}
示例10: sprintf
void CYouLess::GetMeterDetails()
{
std::string sResult;
char szURL[200];
if(m_Password.size() == 0)
{
sprintf(szURL,"http://%s:%d/a",m_szIPAddress.c_str(), m_usIPPort);
}
else
{
sprintf(szURL,"http://%s:%d/a&w=%s",m_szIPAddress.c_str(), m_usIPPort, m_Password.c_str());
}
if (!HTTPClient::GET(szURL,sResult))
{
_log.Log(LOG_ERROR,"YouLess: Error connecting to: %s", m_szIPAddress.c_str());
return;
}
std::vector<std::string> results;
StringSplit(sResult, "\n", results);
if (results.size()<2)
{
_log.Log(LOG_ERROR,"YouLess: Error connecting to: %s", m_szIPAddress.c_str());
return;
}
int fpos;
std::string pusage=stdstring_trim(results[0]);
fpos=pusage.find_first_of(" ");
if (fpos!=std::string::npos)
pusage=pusage.substr(0,fpos);
stdreplace(pusage,",","");
std::string pcurrent=stdstring_trim(results[1]);
fpos=pcurrent.find_first_of(" ");
if (fpos!=std::string::npos)
pcurrent=pcurrent.substr(0,fpos);
stdreplace(pcurrent,",","");
m_meter.powerusage=atol(pusage.c_str());
m_meter.usagecurrent=atol(pcurrent.c_str());
sDecodeRXMessage(this, (const unsigned char *)&m_meter);//decode message
}
示例11: getErrorPosition
static int getErrorPosition(OovStringRef const line, int &charOffset)
{
int lineNum = -1;
OovStringVec tokens = StringSplit(line, ':');
auto iter = std::find_if(tokens.begin(), tokens.end(),
[](OovStringRef const tok)
{ return(isdigit(tok[0])); }
);
int starti = iter-tokens.begin();
if(tokens[starti].getInt(0, INT_MAX, lineNum))
{
if(static_cast<unsigned int>(starti+1) < tokens.size())
{
tokens[starti+1].getInt(0, INT_MAX, charOffset);
}
}
return lineNum;
}
示例12: WHERE
float Meteostick::GetRainSensorCounter(const unsigned char Idx)
{
float counter = 0;
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT sValue FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID==%d) AND (Type==%d) AND (Subtype==%d)", m_HwdID, int(Idx), int(pTypeRAIN), int(sTypeRAIN3));
if (result.size() >0)
{
std::vector<std::string> strarray;
StringSplit(result[0][0], ";", strarray);
if (strarray.size() == 2)
{
counter = static_cast<float>(atof(strarray[1].c_str()));
}
}
return counter;
}
示例13: WHERE
bool CSBFSpot::GetMeter(const unsigned char ID1,const unsigned char ID2, double &musage, double &mtotal)
{
int Idx=(ID1 * 256) + ID2;
std::vector<std::vector<std::string> > result;
result=m_sql.safe_query("SELECT Name, sValue FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID==%d) AND (Type==%d) AND (Subtype==%d)",
m_HwdID, int(Idx), int(pTypeENERGY), int(sTypeELEC2));
if (result.size()<1)
{
return false;
}
std::vector<std::string> splitresult;
StringSplit(result[0][1],";",splitresult);
if (splitresult.size()!=2)
return false;
musage=atof(splitresult[0].c_str());
mtotal=atof(splitresult[1].c_str())/1000.0;
return true;
}
示例14: process_publish
static void process_publish(const string &ip, const string &data, string &answer) {
if(Server::clients.count(ip) > 0) {
// "P;piece;status" (status é: FOUND, NOT_FOUND)
vector<string> cmd_parts;
StringSplit(data,";", &cmd_parts);
string piece = cmd_parts[1];
if(cmd_parts[2] == "NOT_FOUND") {
subsets[piece].status = SUBSET_READY;
} else {
cout << "FOUND !!!! said client " << ip << endl;
//stop_clients();
exit(0);
}
answer = "OK";
} else {
answer = "You are NOT registered on this server";
}
}
示例15: atoi
std::string CNotificationKodi::GetCustomIcon(std::string &szCustom)
{
int iIconLine = atoi(szCustom.c_str());
std::string szRetVal = "Light48";
if (iIconLine < 100) // default set of custom icons
{
std::string sLine = "";
std::ifstream infile;
std::string switchlightsfile = szWWWFolder + "/switch_icons.txt";
infile.open(switchlightsfile.c_str());
if (infile.is_open())
{
int index = 0;
while (!infile.eof())
{
getline(infile, sLine);
if ((sLine.size() != 0) && (index++ == iIconLine))
{
std::vector<std::string> results;
StringSplit(sLine, ";", results);
if (results.size() == 3)
{
szRetVal = results[0] + "48";
break;
}
}
}
infile.close();
}
}
else // Uploaded icons
{
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT Base FROM CustomImages WHERE ID = %d", iIconLine-100);
if (result.size() == 1)
{
std::string sBase = result[0][0];
return sBase;
}
}
// _log.Log(LOG_NORM, "Custom Icon look up for %s returned: '%s'", szCustom.c_str(), szRetVal.c_str());
return szRetVal;
}