• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ splitString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中splitString函数的典型用法代码示例。如果您正苦于以下问题:C++ splitString函数的具体用法?C++ splitString怎么用?C++ splitString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了splitString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:37,代码来源:user_main.c


示例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);
}
开发者ID:epoupon,项目名称:lms,代码行数:24,代码来源:ArtistsView.cpp


示例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;
}
开发者ID:sandeep-datta,项目名称:winguide,代码行数:24,代码来源:Guide.cpp


示例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());
    }
}
开发者ID:ueverything,项目名称:easyserver,代码行数:24,代码来源:Platform.cpp


示例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();
}
开发者ID:Ilyazykov,项目名称:DNA-methylation,代码行数:36,代码来源:SVreader.cpp


示例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");
	}

}
开发者ID:MarquisdeGeek,项目名称:ultra,代码行数:24,代码来源:op_limit.cpp


示例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));
	}
}
开发者ID:BackupTheBerlios,项目名称:freenx-svn,代码行数:36,代码来源:nxclientlib.cpp


示例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;
}
开发者ID:Feechka,项目名称:UOBP,代码行数:24,代码来源:program.c


示例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;
}
开发者ID:abraneo,项目名称:jedox-mirror,代码行数:24,代码来源:FileReaderTXT.cpp


示例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;
}
开发者ID:MichaelCaiser,项目名称:Counting-and-Detecting-Vehicles,代码行数:35,代码来源:FileReader.cpp


示例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;
}
开发者ID:SukkoPera,项目名称:Arduino-Sensoria,代码行数:24,代码来源:TransducerProxy.cpp


示例12: splitString

	/// extern
	vector<string> splitString(string const &text, string const &split)
	{
		return splitString(text, split, 0);
	}
开发者ID:duchien85,项目名称:cellengine,代码行数:5,代码来源:StringReader.cpp


示例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);
//.........这里部分代码省略.........
开发者ID:mturley,项目名称:EmulationStation,代码行数:101,代码来源:ThemeComponent.cpp


示例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:
//.........这里部分代码省略.........
开发者ID:redfish64,项目名称:tangram-es,代码行数:101,代码来源:styleParam.cpp


示例16: nlassert

// ***************************************************************************
void	CSkeletonSpawnScript::parseCache(CScene *scene, CSkeletonModel *skeleton)
{
	uint	i;
	nlassert(scene);
	nlassert(_Cache.empty() || skeleton);

	static std::vector<std::string>	newLines;
	newLines.clear();
	splitString(_Cache,"\n",newLines);

	// **** compare the 2 set of script line to know what to add, and what to remove.
	// NB: this is an O(N2), but the number of spawned objects should be small (0, 1 or 2 surely)
	static std::vector<bool>	srcToRemove;
	static std::vector<bool>	dstToAdd;
	srcToRemove.clear();
	dstToAdd.clear();
	srcToRemove.resize(_Instances.size(), true);
	dstToAdd.resize(newLines.size(), true);
	for(uint i=0;i<_Instances.size();i++)
	{
		for(uint j=0;j<newLines.size();j++)
		{
			// if the new line script is the same than the old one, then reuse!
			// NB: the script line contains an "instance number", so there is no risk of "reuse same twice"
			if(newLines[j] == _Instances[i].ScriptLine)
			{
				srcToRemove[i]= false;
				dstToAdd[j]= false;
			}
		}
	}

	// **** remove the no more used instances
	vector<CInstance>::iterator	it= _Instances.begin();
	for(i=0;i<srcToRemove.size();i++)
	{
		// if must remove this entry
		if(srcToRemove[i])
		{
			// then erase the entry
			if(it->Model)
				scene->deleteInstance(it->Model);
			it= _Instances.erase(it);
		}
		else
			it++;
	}

	// **** create the new instances
	for(i=0;i<dstToAdd.size();i++)
	{
		// if not reused
		if(dstToAdd[i])
		{
			// parse the line
			const std::string				&line= newLines[i];
			static std::vector<string>		words;
			words.clear();
			splitString(line, " ", words);
			if(words.size()>=3)
			{
				// command
				if(words[0]=="objw")
				{
					// format: "objw inst shapeName"
					// inst is a number only used to generate line difference (for cache comparison)
					_Instances.push_back(CInstance());
					CInstance	&inst= _Instances.back();
					inst.ScriptLine= line;

					// Delay the model creation at end of CScene::render()
					CSSSModelRequest	req;
					req.Skel= skeleton;
					req.InstanceId= (uint)_Instances.size()-1;
					req.Shape= words[2];
					// World Spawned Objects are sticked to the root bone (for CLod hiding behavior)
					req.BoneId= 0;
					// but have a special feature to compute their world matrix
					req.SSSWO= true;
					addModelCreationRequest(req, scene);
				}
				else if(words[0]=="objl" && words.size()>=4)
				{
					// format: "objl inst shapeName boneName"
					// inst is a number only used to generate line difference (for cache comparison)

					// get the bone name, but may have space in its name => words[3] is not the correct name
					uint	pos= 0;
					bool	inWord= false;
					uint	wordId= 0;
					// skip first spaces
					while(pos<line.size() && line[pos]==' ')
						pos++;
					// count word until reach
					while(pos<line.size())
					{
						if(line[pos]!=' ')
						{
							if(!inWord)
//.........这里部分代码省略.........
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:101,代码来源:skeleton_spawn_script.cpp


示例17: proClientSocket


//.........这里部分代码省略.........
				break;
			}
			continue;
		}
		//shutdown指令
		if (shutdownFlag){
			break;
		}

		//////////////////////////////////////////////////////////////////////////
		//帧的销毁遵守:谁调用谁负责销毁!!!!!!!!!!!!!!!!!!!
		//关键的命令逻辑处理,逆解析来自客户端的请求帧
		//新建客户端的请求帧,由调用者负责清除
		common_CmdReq_Frame	*clientReqFrame	= CARI_CCP_VOS_NEW(common_CmdReq_Frame);
		initCommonRequestFrame(clientReqFrame);

		//add by xxl 2010-5-5: 需要判断一下此命令是来自web还是一般的client
		if(!bWebType){
			char chHeader = recvBuf[0];
			if ('[' ==chHeader){//判断是否为web发送的命令格式
				bWeb = true;
			}
		}
		//需要重新解析构造请求帧,根据字符串进行转换
		if (bWebType || bWeb){
			string strres = recvBuf,strHeader,strCmd,strParam,strVal,strName;
			int ival =0;
			int index = strres.find_first_of("]");
			strHeader = strres.substr(1,index-1);
			strCmd= strres.substr(index+1);
			
			//1 先构造消息头
			vector<string> resultVec;
			splitString(strHeader, ",", resultVec);
			vector<string>::const_iterator it = resultVec.begin();
			for (;it != resultVec.end(); it++){
				strVal = *it;
				index = strVal.find_first_of("=");
				if (0 < index){
					strName = strVal.substr(0,index);
					strVal  = strVal.substr(index+1);
                    trim(strName);
					trim(strVal);

					//解析关键的参数
					if(isEqualStr("clientID",strName)){
						clientReqFrame->header.sClientID = 0;//web的比较固定
					}
					else if(isEqualStr("modId",strName)){
						clientReqFrame->header.sClientChildModID = stringToInt(strVal.c_str());
					}
					else if(isEqualStr("cmdID",strName)){
						clientReqFrame->body.iCmdCode = stringToInt(strVal.c_str());
					}
					else if(isEqualStr("logUserName",strName)){
						myMemcpy(clientReqFrame->header.strLoginUserName,strVal.c_str(),strVal.length());
					}
				}
			}//end for

			//2 再解析命令名和参数区
			strName = "";
			trim(strCmd);
			index = strCmd.find_first_of(":");
			if (0 < index){
				strName = strCmd.substr(0,index);
开发者ID:gujun,项目名称:sscore,代码行数:67,代码来源:cari_net_socket.cpp


示例18: fName

bool SBMLModelSimulation::LoadSettings(const string& settingsFName)
{
    string fName(settingsFName);

    if(!fName.size())
    {
        Log(Logger::LOG_ERROR)<<"Empty file name for setings file";
        return false;
    }
    else
    {
        map<string, string> settings;
        map<string, string>::iterator it;
        //Read each line in the settings file
        vector<string> lines = getLinesInFile(fName);
        for(u_int i = 0; i < lines.size(); i++)
        {
            vector<string> line = splitString(lines[i], ":");
            if(line.size() == 2)
            {
                settings.insert( pair<string, string>(line[0], line[1]));
            }
            else
            {
                Log(lDebug2)<<"Empty line in settings file: "<<lines[i];
            }
        }

        Log(lDebug3)<<"Settings File =============";
        for (it = settings.begin() ; it != settings.end(); it++ )
        {
            Log(lDebug) << (*it).first << " => " << (*it).second;
        }
        Log(lDebug)<<"===========================";

        //Assign values
        it = settings.find("start");
        mSettings.start = (it != settings.end())   ? toDouble((*it).second) : 0;

        it = settings.find("duration");
        mSettings.duration = (it != settings.end())    ? toDouble((*it).second) : 0;

        it = settings.find("steps");
        mSettings.steps = (it != settings.end())       ? toInt((*it).second) : 50;

        it = settings.find("absolute");
        mSettings.absolute = (it != settings.end())    ? toDouble((*it).second) : 1.e-7;

        it = settings.find("relative");
        mSettings.relative = (it != settings.end())    ? toDouble((*it).second) : 1.e-4;

        it = settings.find("variables");
        if(it != settings.end())
        {
            vector<string> vars = splitString((*it).second, ",");
            for(u_int i = 0; i < vars.size(); i++)
            {
                mSettings.variables.push_back(trim(vars[i]));
            }
        }

        it = settings.find("amount");
        if(it != settings.end())
        {
            vector<string> vars = splitString((*it).second, ",");
            for(u_int i = 0; i < vars.size(); i++)
            {
                string rec = trim(vars[i]);
                if(rec.size())
                {
                    mSettings.amounts.push_back(rec);
                }
            }
        }

        it = settings.find("concentration");
        if(it != settings.end())
        {
            vector<string> vars = splitString((*it).second, ",");
            for(u_int i=0; i < vars.size(); i++)
            {
                string rec = trim(vars[i]);
                if(rec.size())
                {
                    mSettings.concentrations.push_back(rec);
                }
            }
        }
    }

    if(mEngine)
    {
        mEngine->setSimulateOptions(mSettings);
    }

    return true;
}
开发者ID:0u812,项目名称:roadrunner-backup,代码行数:97,代码来源:rrSBMLModelSimulation.cpp


示例19: open_recorder

/*******************************************************************
 * recorders 
 */
EXPORT int open_recorder(struct recorder *my, char *fname, char *flags)
{
	char32 extension;
	char1024 columnlist;
	char **columns;
	time_t now=time(NULL);
	OBJECT *obj=OBJECTHDR(my);
	static int block=0;

	set_recorder(my);

	if (!block) {
		atexit(close_recorder_wrapper);
		block=1;
	}

	columns = (char **)calloc(MAXCOLUMNS, sizeof(char *));
	for(int i=0; i<MAXCOLUMNS; i++){
		columns[i] = (char *)malloc(33);
		memset(columns[i],'\0',32);
	}

	my->fp = (strcmp(fname,"-")==0?stdout:fopen(fname,flags));
	if (my->fp==NULL)
	{
		//gl_error(
		fprintf(stderr, "recorder file %s: %s", fname, strerror(errno));
		my->status = TS_DONE;
		return 0;
	}
	my->type = FT_FILE;
	my->last.ts = TS_ZERO;
	my->status=TS_OPEN;
	my->samples=0;

	/* put useful header information in file first */
	fprintf(my->fp,"# file...... %s\n", my->file);
	fprintf(my->fp,"# date...... %s", asctime(localtime(&now)));
#ifdef WIN32
	fprintf(my->fp,"# user...... %s\n", getenv("USERNAME"));
	fprintf(my->fp,"# host...... %s\n", getenv("MACHINENAME"));
#else
	fprintf(my->fp,"# user...... %s\n", getenv("USER"));
	fprintf(my->fp,"# host...... %s\n", getenv("HOST"));
#endif
	fprintf(my->fp,"# target.... %s %d\n", obj->parent->oclass->name, obj->parent->id);
	fprintf(my->fp,"# trigger... %s\n", my->trigger[0]=='\0'?"(none)":my->trigger);
	fprintf(my->fp,"# interval.. %d\n", my->interval);
	fprintf(my->fp,"# limit..... %d\n", my->limit);
	fprintf(my->fp,"# timestamp,%s\n", my->property);

	/* Split the property list into items */
  splitString(my->property, columns);
	/* Array 'columns' contains the separated items from the property list
	for (int i=0;i<MAXCOLUMNS;i++){
		if (strlen(columns[i])>0)
			fprintf(my->fp,"%s\n",columns[i]);
	}
	*/

	/* Put gnuplot commands in the header portion */
	fprintf(my->fp,"# GNUplot commands below:     \n");
	
	switch (my->output) {
		case SCREEN:
#ifdef WIN32
			fprintf(my->fp, "set terminal windows color;\n");
#else
			fprintf(my->fp, "set terminal x11;\n");
#endif
			break;
		case EPS:
			fprintf(my->fp, "set terminal epslatex;\n");
			strcpy(extension, "EPS");
			break;
		case GIF:
			fprintf(my->fp, "set terminal gif;\n");
			strcpy(extension, "GIF");
			break;
		case JPG:
			fprintf(my->fp, "set terminal jpeg;\n");
			strcpy(extension, "JPG");
			break;
		case PDF:
			fprintf(my->fp, "set terminal pdf;\n");
			strcpy(extension, "PDF");
			break;
		case PNG:
			fprintf(my->fp, "set terminal png;\n");
			strcpy(extension, "PNG");
			break;
		case SVG:
			fprintf(my->fp, "set terminal svg;\n");
			strcpy(extension, "SVG");
			break;
		default:
			fprintf(my->fp, "set terminal jpeg;\n");
//.........这里部分代码省略.........
开发者ID:devendrashelar7,项目名称:gridnetd,代码行数:101,代码来源:tape_plot.cpp


示例20: getKeyNameTables

static KEY_NAME_TABLES_REFERENCE
getKeyNameTables (const char *keyTableName) {
  KEY_NAME_TABLES_REFERENCE keyNameTables = NULL;
  int componentsLeft;
  char **nameComponents = splitString(keyTableName, '-', &componentsLeft);

  if (nameComponents) {
    char **currentComponent = nameComponents;

    if (componentsLeft) {
      const char *keyTableType = (componentsLeft--, *currentComponent++);

      if (strcmp(keyTableType, "kbd") == 0) {
        if (componentsLeft) {
          componentsLeft--; currentComponent++;
          keyNameTables = KEY_NAME_TABLES(keyboard);
        } else {
          logMessage(LOG_ERR, "missing keyboard bindings name");
        }
      } else if (strcmp(keyTableType, "brl") == 0) {
        if (componentsLeft) {
          void *driverObject;
          const char *driverCode = (componentsLeft--, *currentComponent++);

          if (loadBrailleDriver(driverCode, &driverObject, opt_driversDirectory)) {
            char *keyTablesSymbol;

            {
              const char *strings[] = {"brl_ktb_", driverCode};
              keyTablesSymbol = joinStrings(strings, ARRAY_COUNT(strings));
            }

            if (keyTablesSymbol) {
              const KeyTableDefinition *const *keyTableDefinitions;

              if (findSharedSymbol(driverObject, keyTablesSymbol, &keyTableDefinitions)) {
                const KeyTableDefinition *const *currentDefinition = keyTableDefinitions;

                if (componentsLeft) {
                  const char *bindingsName = (componentsLeft--, *currentComponent++);

                  while (*currentDefinition) {
                    if (strcmp(bindingsName, (*currentDefinition)->bindings) == 0) {
                      keyNameTables = (*currentDefinition)->names;
                      break;
                    }

                    currentDefinition += 1;
                  }

                  if (!keyNameTables) {
                    logMessage(LOG_ERR, "unknown %s braille driver bindings name: %s",
                               driverCode, bindingsName);
                  }
                } else {
                  logMessage(LOG_ERR, "missing braille driver bindings name");
                }
              }

              free(keyTablesSymbol);
            } else {
              logMallocError();
            }
          }
        } else {
          logMessage(LOG_ERR, "missing braille driver code");
        }
      } else {
        logMessage(LOG_ERR, "unknown key table type: %s", keyTableType);
      }
    } else {
      logMessage(LOG_ERR, "missing key table type");
    }
  }

  if (keyNameTables) {
    if (componentsLeft) {
      logMessage(LOG_ERR, "too many key table na 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ split_block函数代码示例发布时间:2022-05-30
下一篇:
C++ splitPath函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap