本文整理汇总了C++中splitString函数的典型用法代码示例。如果您正苦于以下问题:C++ splitString函数的具体用法?C++ splitString怎么用?C++ splitString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了splitString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: passesFilter
bool ICACHE_FLASH_ATTR passesFilter(char *appTokens[]) {
int filterID;
bool anyMatched = false;
int activeFilters = 0;
for (filterID = 0; filterID < FILTER_COUNT; filterID++) {
if (strlen(sysCfg.filters[filterID]) > 0)
activeFilters++;
}
if (activeFilters == 0) {
INFOP("No filters\n");
return true;
}
for (filterID = 0; filterID < FILTER_COUNT && !anyMatched; filterID++) {
if (strlen(sysCfg.filters[filterID]) > 0) {
bool match = true;
char *filterTokens[10];
char bfr[100]; // splitString overwrites filter template!
strcpy(bfr, sysCfg.filters[filterID]);
int tokenCount = splitString((char *) bfr, '/', filterTokens);
int tkn;
for (tkn = 0; tkn < tokenCount && match; tkn++) {
if (strcmp("+", filterTokens[tkn]) == 0)
continue;
if (strcmp("#", filterTokens[tkn]) == 0)
break;
if (strcmp(filterTokens[tkn], appTokens[tkn]) != 0)
match = false;
}
if (match)
anyMatched = true;
}
}
INFOP("Filter matched %d - (%s)\n", anyMatched, sysCfg.filters[filterID]);
return anyMatched;
}
示例2: splitString
void
Artists::addSome()
{
auto searchKeywords = splitString(_search->text().toUTF8(), " ");
auto clusterIds = _filters->getClusterIds();
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
bool moreResults;
auto artists = Artist::getByFilter(LmsApp->getDboSession(),
clusterIds,
searchKeywords,
_container->count(), 20, moreResults);
for (auto artist : artists)
{
Wt::WTemplate* entry = _container->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Artists.template.entry"));
entry->bindWidget("name", LmsApplication::createArtistAnchor(artist));
}
_showMore->setHidden(!moreResults);
}
示例3: fromString
static bool fromString(const CString& str, HeadingStyle& hs)
{
CStringArray parts;
splitString(str, parts, _T('|'));
if (parts.GetCount() != 9)
return false;
memset(&hs, 0, sizeof(hs));
_tcsncpy(hs.fontFamily, parts[0], LF_FACESIZE);
hs.fontPointSize = _ttoi(parts[1]);
hs.fontBold = parts[2] == _T("1");
hs.fontItalic = parts[3] == _T("1");
hs.fontUnderline = parts[4] == _T("1");
hs.fontColor = _ttoi(parts[5]);
hs.breakPage = parts[6] == _T("1");
hs.numbered = parts[7] == _T("1");
hs.justify = HeadingStyle::_justify(_ttoi(parts[8]));
if (hs.fontPointSize < 0 || hs.fontPointSize > 99 ||
hs.justify < 0 || hs.justify > 2 ||
hs.fontFamily[0] == 0)
return false;
return true;
}
示例4: strncpy
void Platform::createDirectorys(const char* path)
{
char szFileNameTmp[1024];
strncpy(szFileNameTmp, path, 1024);
replaceBacklashPath(szFileNameTmp);
std::string strPathName = szFileNameTmp;
size_t pos = strPathName.find_last_of("\\");
std::string strPath = strPathName.substr(0,pos);
std::string strName = strPathName.substr(pos+1,strPathName.length());
vector<string> list;
splitString(list, strPath, "/");
string strPathTemp;
for (size_t i=0; i<list.size(); i++) {
strPathTemp += list[i];
strPathTemp += "/";
if (strPathTemp == "./")
continue;
if (!Platform::isDirExist(strPathTemp.c_str()))
Platform::mkdir(strPathTemp.c_str());
}
}
示例5: fin
void CSVreader::readData( const string &filename, const string &csvdelimiter, vector< vector<double> > &sarr, int numY, int numX )
{
numY++; numX;
ifstream fin(filename.c_str());
string s;
vector<string> selements;
vector<double> delements;
int x = 0;
while ( !fin.eof() )
{
getline(fin, s);
if ( !s.empty() )
{
splitString(s, selements, csvdelimiter);
for ( int i=0; i<selements.size(); i++ )
{
delements.push_back(stringToDouble(selements[i]));
if (i>=numX) break;
}
sarr.push_back(delements);
selements.clear();
delements.clear();
}
x++;
if (x>=numY) break;
}
fin.close();
}
示例6: splitString
void
UltraRemapOpLimit::process(sgxString &resultPattern, const sgxString &source) const {
std::vector<sgxString> result;
int argCount = splitString(result, source, ' ');
if (argCount >= 3) {
int v = atoi(result[0].c_str());
int minimum = atoi(result[1].c_str());
int maximum = atoi(result[2].c_str());
if (v < minimum) {
v = minimum;
} else if (v > maximum) {
v = maximum;
}
intToString(resultPattern, v);
} else {
log(LOG_WARNING, "op.limit didn't have 3 args");
}
}
示例7: sshRequestConfirmation
void NXClientLib::processParseStdout()
{
QString message = nxsshProcess.readAllStandardOutput().data();
// Message 211 is sent if ssh is asking to continue with an unknown host
if (session.parseResponse(message) == 211) {
emit sshRequestConfirmation(message);
}
cout << message.toStdString();
emit stdout(message);
QStringList messages = splitString(message);
QStringList::const_iterator i;
// On some connections this is sent via stdout instead of stderr?
if (proxyData.encrypted && isFinished && message.contains("NX> 999 Bye")) {
QString returnMessage;
returnMessage = "NX> 299 Switching connection to: ";
returnMessage += proxyData.proxyIP + ":" + QString::number(proxyData.port) + " cookie: " + proxyData.cookie + "\n";
write(returnMessage);
} else if (message.contains("NX> 287 Redirected I/O to channel descriptors"))
emit callbackWrite(tr("The session has been started successfully"));
for (i = messages.constBegin(); i != messages.constEnd(); ++i) {
if ((*i).contains("Password")) {
emit callbackWrite(tr("Authenticating with NX server"));
password = true;
}
if (!isFinished)
write(session.parseSSH(*i));
else
write(parseSSH(*i));
}
}
示例8: findProgram
static char *
findProgram (const char *name) {
char *path = NULL;
const char *string;
if ((string = getenv("PATH"))) {
int count;
char **array;
if ((array = splitString(string, ':', &count))) {
int index;
for (index=0; index<count; ++index) {
const char *directory = array[index];
if (!*directory) directory = ".";
if ((path = testProgram(directory, name))) break;
}
deallocateStrings(array);
}
}
return path;
}
示例9: getDataStrings
PPaths FileReaderTXT::getDataPaths(int num)
{
vector<string> stringList = getDataStrings(num, ':');
PPaths result(new vector<IdentifiersType>());
for (vector<string>::iterator iset = stringList.begin(); iset != stringList.end(); ++iset) {
vector<string> subsetStrings;
IdentifiersType subset;
splitString(*iset, &subsetStrings, ',');
char *p;
IdentifiersType path;
for (vector<string>::const_iterator i = subsetStrings.begin(); i != subsetStrings.end(); ++i) {
long li = strtol((*i).c_str(), &p, 10);
if (*p == 0) {
path.push_back(li);
}
}
result->push_back(path);
}
return result;
}
示例10: splitString
/**
* This method creates a ConnectionConfig object based on the data in a string, the data in the string must contain the
* port, the host and the url of a web service. The format of the string (rInformation) must be equal to as follows:
* "port,host,url". If the information is incorrect this method return a null pointer.
* Example if rInformation is equal to "80,localhost,http//localhost:80/WebAppCar/service/rest/embedded/addReport"
* the method return a pointer to a ConnectionConfig which the port is 80, the host is localhost and the url is
* http//localhost:80/WebAppCar/service/rest/embedded/addReport. <p>
*
* @param rInformation The information required to create a ConnectionConfig (A string with the port, the host and the url)
* @return ConnectionConfig* A pointer to a ConnectionConfig which was created with the information on the string.
*/
ConnectionConfig* FileReader::createConnectionConfig(string rInformation){
//Vector that contains the data of the information
vector<string> string_list;
//Split the information based on the character separator ","
splitString(rInformation, INFORMATION_SEPARATOR, string_list);
//Check if the information has been divided in three parts
if(string_list.size() == SIZE_CONNEC_CONFIG){
string string_port = string_list.at(POS_PORT_WEBCON);
string host = string_list.at(POS_HOST_WEBCON);
string url = string_list.at(POS_URL_WEBCON);
//Check if the port is a number
if(!isNumber(string_port)){
return NULL;
}
int port = atoi(string_port.c_str());
ConnectionConfig* p_connection_config = new ConnectionConfig(port,host,url);
return p_connection_config;
}
return NULL;
}
示例11: strcat
boolean TransducerProxy::read (char*& reply) {
boolean ret;
char buf[8] = {0}, *r;
strcat (buf, "REA ");
strcat (buf, name);
strcat (buf, "\n");
if ((ret = srvpx -> sendcmd (buf, r))) {
char *p[2];
if (splitString (r, p, 2) != 2) {
DPRINT (F("AAA:"));
DPRINTLN (r);
ret = false;
} else if (strcmp (p[0], name) != 0) {
DPRINT (F("AAAAAA: "));
DPRINTLN (r);
ret = false;
} else {
reply = p[1];
}
}
return ret;
}
示例12: splitString
/// extern
vector<string> splitString(string const &text, string const &split)
{
return splitString(text, split, 0);
}
示例13: setDefaults
void ThemeComponent::readXML(std::string path)
{
if(mPath == path)
return;
setDefaults();
deleteComponents();
mPath = path;
if(path.empty())
return;
LOG(LogInfo) << "Loading theme \"" << path << "\"...";
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file(path.c_str());
if(!result)
{
LOG(LogError) << "Error parsing theme \"" << path << "\"!\n" << " " << result.description();
return;
}
pugi::xml_node root;
if(!mDetailed)
{
//if we're using the basic view, check if there's a basic version of the theme
root = doc.child("basicTheme");
}
if(!root)
{
root = doc.child("theme");
}
if(!root)
{
LOG(LogError) << "No theme tag found in theme \"" << path << "\"!";
return;
}
//load non-component theme stuff
mColorMap["primary"] = resolveColor(root.child("listPrimaryColor").text().get(), mColorMap["primary"]);
mColorMap["secondary"] = resolveColor(root.child("listSecondaryColor").text().get(), mColorMap["secondary"]);
mColorMap["selector"] = resolveColor(root.child("listSelectorColor").text().get(), mColorMap["selector"]);
mColorMap["selected"] = resolveColor(root.child("listSelectedColor").text().get(), mColorMap["selected"]);
mColorMap["description"] = resolveColor(root.child("descColor").text().get(), mColorMap["description"]);
mColorMap["fastSelect"] = resolveColor(root.child("fastSelectColor").text().get(), mColorMap["fastSelect"]);
mBoolMap["hideHeader"] = root.child("hideHeader") != 0;
mBoolMap["hideDividers"] = root.child("hideDividers") != 0;
//GuiBox theming data
mBoxData.backgroundPath = expandPath(root.child("boxBackground").text().get());
mBoxData.backgroundTiled = root.child("boxBackgroundTiled") != 0;
mBoxData.horizontalPath = expandPath(root.child("boxHorizontal").text().get());
mBoxData.horizontalTiled = root.child("boxHorizontalTiled") != 0;
mBoxData.verticalPath = expandPath(root.child("boxVertical").text().get());
mBoxData.verticalTiled = root.child("boxVerticalTiled") != 0;
mBoxData.cornerPath = expandPath(root.child("boxCorner").text().get());
//list stuff
mBoolMap["listCentered"] = !root.child("listLeftAlign");
mFloatMap["listOffsetX"] = strToFloat(root.child("listOffsetX").text().get(), mFloatMap["listOffsetX"]);
mFloatMap["listTextOffsetX"] = strToFloat(root.child("listTextOffsetX").text().get(), mFloatMap["listTextOffsetX"]);
//game image stuff
std::string artPos = root.child("gameImagePos").text().get();
std::string artDim = root.child("gameImageDim").text().get();
std::string artOrigin = root.child("gameImageOrigin").text().get();
std::string artPosX, artPosY, artWidth, artHeight, artOriginX, artOriginY;
splitString(artPos, ' ', &artPosX, &artPosY);
splitString(artDim, ' ', &artWidth, &artHeight);
splitString(artOrigin, ' ', &artOriginX, &artOriginY);
mFloatMap["gameImageOffsetX"] = resolveExp(artPosX, mFloatMap["gameImageOffsetX"]);
mFloatMap["gameImageOffsetY"] = resolveExp(artPosY, mFloatMap["gameImageOffsetY"]);
mFloatMap["gameImageWidth"] = resolveExp(artWidth, mFloatMap["gameImageWidth"]);
mFloatMap["gameImageHeight"] = resolveExp(artHeight, mFloatMap["gameImageHeight"]);
mFloatMap["gameImageOriginX"] = resolveExp(artOriginX, mFloatMap["gameImageOriginX"]);
mFloatMap["gameImageOriginY"] = resolveExp(artOriginY, mFloatMap["gameImageOriginY"]);
mStringMap["imageNotFoundPath"] = expandPath(root.child("gameImageNotFound").text().get());
//sounds
mSoundMap["menuScroll"]->loadFile(expandPath(root.child("menuScrollSound").text().get()));
mSoundMap["menuSelect"]->loadFile(expandPath(root.child("menuSelectSound").text().get()));
mSoundMap["menuBack"]->loadFile(expandPath(root.child("menuBackSound").text().get()));
mSoundMap["menuOpen"]->loadFile(expandPath(root.child("menuOpenSound").text().get()));
//fonts
mListFont = resolveFont(root.child("listFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::MEDIUM)->getSize());
mDescFont = resolveFont(root.child("descriptionFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::SMALL)->getSize());
mFastSelectFont = resolveFont(root.child("fastSelectFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::LARGE)->getSize());
//actually read the components
createComponentChildren(root, this);
//.........这里部分代码省略.........
示例14: main
int main (int argc, char* argv[])
{
SAMPLE sample; /* training sample */
LEARN_PARM learn_parm;
KERNEL_PARM kernel_parm;
STRUCT_LEARN_PARM struct_parm;
STRUCTMODEL structmodel;
int alg_type;
svm_struct_learn_api_init(argc,argv);
read_input_parameters(argc,argv,trainfile,modelfile,&verbosity,
&struct_verbosity,&struct_parm,&learn_parm,
&kernel_parm,&alg_type);
if(struct_verbosity>=1) {
//verbose = true;
printf("Reading training examples..."); fflush(stdout);
}
/* read the training examples */
sample=read_struct_examples(trainfile,&struct_parm);
if(struct_verbosity>=1) {
printf("done\n"); fflush(stdout);
}
string config_tmp;
bool update_loss_function = false;
if(Config::Instance()->getParameter("update_loss_function", config_tmp)) {
update_loss_function = config_tmp.c_str()[0] == '1';
}
printf("[Main] update_loss_function=%d\n", (int)update_loss_function);
if(!update_loss_function) {
printf("update_loss_function should be true\n");
exit(-1);
}
eUpdateType updateType = UPDATE_NODE_EDGE;
if(Config::Instance()->getParameter("update_type", config_tmp)) {
updateType = (eUpdateType)atoi(config_tmp.c_str());
}
printf("[Main] update_type=%d\n", (int)updateType);
mkdir(loss_dir, 0777);
// check if parameter vector files exist
const char* parameter_vector_dir = "parameter_vector";
int idx = 0;
string parameter_vector_dir_last = findLastFile(parameter_vector_dir, "", &idx);
string parameter_vector_file_pattern = parameter_vector_dir_last + "/iteration_";
int idx_1 = 1;
string parameter_vector_file_last = findLastFile(parameter_vector_file_pattern, ".txt", &idx_1);
printf("[Main] Checking parameter vector file %s\n", parameter_vector_file_last.c_str());
// vectors used to store RF weights
vector<double>* alphas = new vector<double>[sample.n];
vector<double>* alphas_edge = 0;
if(updateType == UPDATE_NODE_EDGE) {
alphas_edge = new vector<double>[sample.n];
}
int alphas_idx = 0;
if(fileExists("alphas.txt") && fileExists(parameter_vector_file_last)) {
// Loading alpha coefficients
ifstream ifs("alphas.txt");
string line;
int lineIdx = 0;
while(lineIdx < sample.n && getline(ifs, line)) {
vector<string> tokens;
splitString(line, tokens);
for(vector<string>::iterator it = tokens.begin();
it != tokens.end(); ++it) {
alphas[lineIdx].push_back(atoi(it->c_str()));
}
++lineIdx;
}
ifs.close();
if(lineIdx > 0) {
alphas_idx = alphas[0].size();
}
// Loading parameters
printf("[Main] Found parameter vector file %s\n", parameter_vector_file_last.c_str());
struct_parm.ssvm_iteration = idx + 1;
update_output_dir(struct_parm.ssvm_iteration);
//EnergyParam param(parameter_vector_file_last.c_str());
//updateCoeffs(sample, param, struct_parm, updateType, alphas, alphas_idx);
//alphas_idx = 1;
} else {
struct_parm.ssvm_iteration = 0;
// insert alpha coefficients for first iteration
for(int i = 0; i < sample.n; ++i) {
alphas[i].push_back(1);
}
ofstream ofs("alphas.txt", ios::app);
int i = 0;
//.........这里部分代码省略.........
开发者ID:alucchi,项目名称:structured_prediction_for_segmentation,代码行数:101,代码来源:svm_struct_main_loss_update.c
示例15: switch
StyleParam::Value StyleParam::parseString(StyleParamKey key, const std::string& _value) {
switch (key) {
case StyleParamKey::extrude: {
return parseExtrudeString(_value);
}
case StyleParamKey::text_wrap: {
int textWrap;
if (_value == "false") {
return std::numeric_limits<uint32_t>::max();
}
if (_value == "true") {
return uint32_t(15); // DEFAULT
}
if (parseInt(_value, textWrap) > 0 && textWrap > 0) {
return static_cast<uint32_t>(textWrap);
}
return std::numeric_limits<uint32_t>::max();
}
case StyleParamKey::text_offset:
case StyleParamKey::offset: {
UnitVec<glm::vec2> vec;
if (!parseVec2(_value, { Unit::pixel }, vec) || std::isnan(vec.value.y)) {
LOGW("Invalid offset parameter '%s'.", _value.c_str());
}
return vec.value;
}
case StyleParamKey::size: {
UnitVec<glm::vec2> vec;
if (!parseVec2(_value, { Unit::pixel }, vec)) {
LOGW("Invalid size parameter '%s'.", _value.c_str());
}
return vec.value;
}
case StyleParamKey::transition_hide_time:
case StyleParamKey::transition_show_time:
case StyleParamKey::transition_selected_time:
case StyleParamKey::text_transition_hide_time:
case StyleParamKey::text_transition_show_time:
case StyleParamKey::text_transition_selected_time: {
float time = 0.0f;
if (!parseTime(_value, time)) {
LOGW("Invalid time param '%s'", _value.c_str());
}
return time;
}
case StyleParamKey::text_font_family:
case StyleParamKey::text_font_weight:
case StyleParamKey::text_font_style: {
std::string normalized = _value;
std::transform(normalized.begin(), normalized.end(), normalized.begin(), ::tolower);
return normalized;
}
case StyleParamKey::anchor:
case StyleParamKey::text_anchor: {
LabelProperty::Anchors anchors;
for (auto& anchor : splitString(_value, ',')) {
if (anchors.count == LabelProperty::max_anchors) { break; }
LabelProperty::Anchor labelAnchor;
if (LabelProperty::anchor(anchor, labelAnchor)) {
anchors.anchor[anchors.count++] = labelAnchor;
} else {
LOG("Invalid anchor %s", anchor.c_str());
}
}
return anchors;
}
case StyleParamKey::placement: {
LabelProperty::Placement placement = LabelProperty::Placement::vertex;
if (!LabelProperty::placement(_value, placement)) {
LOG("Invalid placement parameter, Setting vertex as default.");
}
return placement;
}
case StyleParamKey::text_align:
case StyleParamKey::text_source:
case StyleParamKey::text_transform:
case StyleParamKey::sprite:
case StyleParamKey::sprite_default:
case StyleParamKey::style:
case StyleParamKey::outline_style:
case StyleParamKey::repeat_group:
case StyleParamKey::text_repeat_group:
return _value;
case StyleParamKey::text_font_size: {
float fontSize = 0.f;
if (!parseFontSize(_value, fontSize)) {
LOGW("Invalid font-size '%s'.", _value.c_str());
}
return fontSize;
}
case StyleParamKey::flat:
case StyleParamKey::interactive:
case StyleParamKey::text_interactive:
case StyleParamKey::tile_edges:
case StyleParamKey::visible:
case StyleParamKey::text_visible:
case StyleParamKey::outline_visible:
case StyleParamKey::collide:
case StyleParamKey::text_optional:
//.........这里部分代码省略.........