当前位置: 首页>>代码示例>>C++>>正文


C++ sep函数代码示例

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


在下文中一共展示了sep函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sep

double PatchyDisc::computePairEnergy(unsigned int particle1, double position1[],
    double orientation1[], unsigned int particle2, double position2[], double orientation2[])
{
    // Separation vector.
    std::vector<double> sep(2);

    // Calculate disc separation.
    sep[0] = position1[0] - position2[0];
    sep[1] = position1[1] - position2[1];

    // Enforce minimum image.
    box.minimumImage(sep);

    // Calculate squared norm of vector.
    double normSqd = sep[0]*sep[0] + sep[1]*sep[1];

    // Discs overlap.
    if (normSqd < 1) return INF;

    // Total interaction energy sum.
    double energy = 0;

    // Test interactions between all patch pairs.
    for (unsigned int i=0;i<maxInteractions;i++)
    {
        // Compute position of patch i on first disc.
        std::vector<double> coord1(2);
        coord1[0] = position1[0] + 0.5*(orientation1[0]*cosTheta[i] - orientation1[1]*sinTheta[i]);
        coord1[1] = position1[1] + 0.5*(orientation1[0]*sinTheta[i] + orientation1[1]*cosTheta[i]);

        // Enforce periodic boundaries.
        box.periodicBoundaries(coord1);

        for (unsigned int j=0;j<maxInteractions;j++)
        {
            // Compute position of patch j on second disc.
            std::vector<double> coord2(2);
            coord2[0] = position2[0] + 0.5*(orientation2[0]*cosTheta[j] - orientation2[1]*sinTheta[j]);
            coord2[1] = position2[1] + 0.5*(orientation2[0]*sinTheta[j] + orientation2[1]*cosTheta[j]);

            // Enforce periodic boundaries.
            box.periodicBoundaries(coord2);

            // Calculate patch separation.
            sep[0] = coord1[0] - coord2[0];
            sep[1] = coord1[1] - coord2[1];

            // Enforce minimum image.
            box.minimumImage(sep);

            // Calculate squared norm of vector.
            normSqd = sep[0]*sep[0] + sep[1]*sep[1];

            // Patches interact.
            if (normSqd < squaredCutOffDistance)
                energy -= interactionEnergy;
        }
    }

    return energy;
}
开发者ID:edwardwas,项目名称:vmmc,代码行数:61,代码来源:PatchyDisc.cpp

示例2: main

int main(int argc, char * argv[]) {
	if(argc != 2) {
		std::cerr << "Usage: " << argv[0] << " csvfile.csv" << std::endl;
		exit(EXIT_FAILURE);
	}//if

	CsvParser cp(argv[1]);
	std::cout << "Parsing ..." << std::endl;

	const auto & data_ref = cp.parse();
	if(data_ref.size() == 0) {
		std::cout << "No Data Available." << std::endl;
		return 0;
	}//if

	auto row_max = data_ref.size();
	auto col_max = data_ref[0].size();
	std::string line;
	std::vector<std::string> line_param;
	boost::char_separator<char> sep("[], ");

	// INTERACTIVE MODE
	std::cout << "Interactive Mode: Ctrl-D to Exit" << std::endl;
	std::cout << "list all the data: " << std::endl;
	std::cout << ">> list" << std::endl;
	std::cout << "output to file: " << std::endl;
	std::cout << ">> [Row_Begin,Row_End][Col_Begin,Col_End] FileName"
		<< std::endl;
	std::cout << "Get Data from data[Row][Column]: " << std::endl;
	std::cout << ">> Row,Column" << std::endl;
	std::cout << "Row size: " << row_max << " Col size: " << col_max << std::endl;
	while(1) {
		line.clear();
		// OUTPUT Title
		for(auto i : data_ref[0])
			std::cout << i << ' ';
		std::cout << std::endl;
		// GET INPUT
		do {
			std::cout << ">> ";
			std::getline(std::cin, line);
		} while(line.empty() && std::cin);

		// Test Ctrl-D
		if(!std::cin) {
			std::cout << std::endl;
			break;
		}//if

		// PARSE INPUT
		line_param.clear();
		boost::tokenizer<boost::char_separator<char>> tok(line, sep);
		std::copy(tok.begin(), tok.end(), std::back_inserter(line_param));

		try {
			switch(line_param.size()) {
			case 1: {
					if(line_param[0] == "l" || line_param[0] == "list") {
						std::size_t line_counter = 0;
						auto i = data_ref.begin(), i_end = data_ref.end();
						std::advance(i, 1); // skip the title
						for(; i != i_end; ++i) {
							std::cout << ++line_counter << ": ";
							for(auto j : *i) {
								std::cout << j << ',';
							}//for
							std::cout << "\b \b" << std::endl;
						}//for
					}//if
				}
				break;
			case 2: {
					auto row = std::stoi(line_param[0]);
					auto col = std::stoi(line_param[1]);
					if(row >= row_max || col >= col_max) {
						std::cout << "Out of Range!" << std::endl;
					} else {
						std::cout << data_ref[row][col] << std::endl;
					}//if-else
				}
				break;
			case 5: {
					std::ofstream out(line_param[4]);

					for(auto row_iter = std::stoi(line_param[0])-1,
								row_end = std::stoi(line_param[1]);
							row_iter != row_end;
							++row_iter)
					{
						for(auto col_iter = std::stoi(line_param[2])-1,
									col_end = std::stoi(line_param[3]);
								col_iter != col_end;
								++col_iter)
						{
							out << data_ref[row_iter][col_iter] << ',';
						}//for
						out << std::endl;
					}//for

					out.close();
//.........这里部分代码省略.........
开发者ID:SkyJunxun,项目名称:Information,代码行数:101,代码来源:parse.cpp

示例3: item_buffer

void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size)
{	
	// Early exit on an empty binary bucket.
	if (bin_bucket_size <= 1) return;

	if (NULL == bin_bucket)
	{
		llerrs << "unpackBinaryBucket failed.  bin_bucket is NULL." << llendl;
		return;
	}

	// Convert the bin_bucket into a string.
	std::vector<char> item_buffer(bin_bucket_size+1);
	memcpy(&item_buffer[0], bin_bucket, bin_bucket_size);	/* Flawfinder: ignore */
	item_buffer[bin_bucket_size] = '\0';
	std::string str(&item_buffer[0]);

	lldebugs << "item buffer: " << str << llendl;

	// Tokenize the string.
	typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
	boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
	tokenizer tokens(str, sep);
	tokenizer::iterator iter = tokens.begin();

	// Extract all values.
	LLUUID item_id;
	item_id.generate();
	setUUID(item_id);

	LLAssetType::EType type;
	type = (LLAssetType::EType)(atoi((*(iter++)).c_str()));
	setType( type );
	
	LLInventoryType::EType inv_type;
	inv_type = (LLInventoryType::EType)(atoi((*(iter++)).c_str()));
	setInventoryType( inv_type );

	std::string name((*(iter++)).c_str());
	rename( name );
	
	LLUUID creator_id((*(iter++)).c_str());
	LLUUID owner_id((*(iter++)).c_str());
	LLUUID last_owner_id((*(iter++)).c_str());
	LLUUID group_id((*(iter++)).c_str());
	PermissionMask mask_base = strtoul((*(iter++)).c_str(), NULL, 16);
	PermissionMask mask_owner = strtoul((*(iter++)).c_str(), NULL, 16);
	PermissionMask mask_group = strtoul((*(iter++)).c_str(), NULL, 16);
	PermissionMask mask_every = strtoul((*(iter++)).c_str(), NULL, 16);
	PermissionMask mask_next = strtoul((*(iter++)).c_str(), NULL, 16);
	LLPermissions perm;
	perm.init(creator_id, owner_id, last_owner_id, group_id);
	perm.initMasks(mask_base, mask_owner, mask_group, mask_every, mask_next);
	setPermissions(perm);
	//lldebugs << "perm: " << perm << llendl;

	LLUUID asset_id((*(iter++)).c_str());
	setAssetUUID(asset_id);

	std::string desc((*(iter++)).c_str());
	setDescription(desc);
	
	LLSaleInfo::EForSale sale_type;
	sale_type = (LLSaleInfo::EForSale)(atoi((*(iter++)).c_str()));
	S32 price = atoi((*(iter++)).c_str());
	LLSaleInfo sale_info(sale_type, price);
	setSaleInfo(sale_info);
	
	U32 flags = strtoul((*(iter++)).c_str(), NULL, 16);
	setFlags(flags);

	time_t now = time(NULL);
	setCreationDate(now);
}
开发者ID:Kiera,项目名称:Crow,代码行数:74,代码来源:llinventory.cpp

示例4: Execute

	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		const Anope::string &target = params[0];
		const Anope::string &modes = params[1];

		Reference<Channel> c = Channel::Find(target);
		if (!c)
			source.Reply(_("Channel \002{0}\002 doesn't exist."), target);
		else if (c->bouncy_modes)
			source.Reply(_("Services is unable to change modes. Are your servers' U:lines configured correctly?"));
		else if (modes.equals_ci("CLEAR"))
		{
			bool all = params.size() > 2 && params[2].equals_ci("ALL");

			const Channel::ModeList chmodes = c->GetModes();
			for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it)
				c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false);

			if (!c)
			{
				source.Reply(_("Modes cleared on %s and the channel destroyed."), target.c_str());
				return;
			}

			if (all)
			{
				for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
				{
					ChanUserContainer *uc = it->second;

					if (uc->user->HasMode("OPER"))
						continue;

					for (size_t i = uc->status.Modes().length(); i > 0; --i)
						c->RemoveMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false);
				}

				source.Reply(_("All modes cleared on \002{0}\002."), c->name);
			}
			else
				source.Reply(_("Non-status modes cleared on \002{0}\002."), c->name);
		}
		else
		{
			spacesepstream sep(modes + (params.size() > 2 ? " " + params[2] : ""));
			Anope::string mode;
			int add = 1;
			Anope::string log_modes, log_params;

			sep.GetToken(mode);
			for (unsigned i = 0; i < mode.length() && c; ++i)
			{
				char ch = mode[i];

				if (ch == '+')
				{
					add = 1;
					log_modes += "+";
					continue;
				}
				else if (ch == '-')
				{
					add = 0;
					log_modes += "-";
					continue;
				}

				ChannelMode *cm = ModeManager::FindChannelModeByChar(ch);
				if (!cm)
					continue;

				Anope::string param, param_log;
				if (cm->type != MODE_REGULAR)
				{
					if (cm->type == MODE_PARAM && !add && anope_dynamic_static_cast<ChannelModeParam *>(cm)->minus_no_arg)
						;
					else if (!sep.GetToken(param))
						continue;

					param_log = param;

					if (cm->type == MODE_STATUS)
					{
						User *targ = User::Find(param, true);
						if (targ == NULL || c->FindUser(targ) == NULL)
							continue;
						param = targ->GetUID();
					}
				}

				log_modes += cm->mchar;
				if (!param.empty())
					log_params += " " + param_log;

				if (add)
					c->SetMode(source.service, cm, param, false);
				else
					c->RemoveMode(source.service, cm, param, false);
			}

//.........这里部分代码省略.........
开发者ID:SaberUK,项目名称:anope,代码行数:101,代码来源:mode.cpp

示例5: sep

void LLHTTPNode::addNode(const std::string& path, LLHTTPNode* nodeToAdd)
{
	typedef boost::tokenizer< boost::char_separator<char> > tokenizer;
	boost::char_separator<char> sep("/", "", boost::drop_empty_tokens);
	tokenizer tokens(path, sep);
	tokenizer::iterator iter = tokens.begin();
	tokenizer::iterator end = tokens.end();

	LLHTTPNode* node = this;
	for(; iter != end; ++iter)
	{
		LLHTTPNode* child = node->impl.findNamedChild(*iter);
		if (!child) { break; }
		node = child;
	}
	
	if (iter == end)
	{
		llwarns << "LLHTTPNode::addNode: already a node that handles "
			<< path << llendl;
		return;
	}
	
	while (true)
	{
		std::string pathPart = *iter;
		
		++iter;
		bool lastOne = iter == end;
		
		LLHTTPNode* nextNode = lastOne ? nodeToAdd : new LLHTTPNode();
		
		switch (pathPart[0])
		{
			case '<':
				// *NOTE: This should really validate that it is of
				// the proper form: <wildcardkey> so that the substr()
				// generates the correct key name.
				node->impl.mWildcardChild = nextNode;
				node->impl.mWildcardName = pathPart;
				if(node->impl.mWildcardKey.empty())
				{
					node->impl.mWildcardKey = pathPart.substr(
						1,
						pathPart.size() - 2);
				}
				break;
			case '*':
				node->impl.mWildcardChild = nextNode;
				if(node->impl.mWildcardName.empty())
				{
					node->impl.mWildcardName = pathPart;
				}
				break;
			
			default:
				node->impl.mNamedChildren[pathPart] = nextNode;
		}
		nextNode->impl.mParentNode = node;

		if (lastOne) break;
		node = nextNode;
	}
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:64,代码来源:llhttpnode.cpp

示例6: root

Set::Set(const System& sys, double eps) : root(new SetLeaf(YES)), Rn(sys.nb_var) {
	SepFwdBwd sep(sys);
	sep.contract(*this,eps);
}
开发者ID:ClementAubry,项目名称:ibex-lib,代码行数:4,代码来源:ibex_Set.cpp

示例7: setName

int Observable2D::ParseObservable2D(std::string& type, 
                                     boost::tokenizer<boost::char_separator<char> >* tok, 
                                     boost::tokenizer<boost::char_separator<char> >::iterator& beg, 
                                     std::string& infilename, 
                                     std::ifstream& ifile,
                                     int lineNo,
                                     int rank)
{
    if (infilename.find("\\/") == std::string::npos) filepath = infilename.substr(0, infilename.find_last_of("\\/") + 1);
    if (std::distance(tok->begin(), tok->end()) < 12) {
        setName(*beg);
        ++beg;
        if (std::distance(tok->begin(), tok->end()) < 4) {
            if(rank == 0) throw std::runtime_error("ERROR: lack of information on " + name + " in " + infilename + " at line number" + boost::lexical_cast<std::string>(lineNo));
            else sleep (2);
        }
        std::string toMCMC = *beg;
        if (toMCMC.compare("MCMC") == 0)
            setTMCMC(true);
        else if (toMCMC.compare("noMCMC") == 0)
            setTMCMC(false);
        else {
            if (rank == 0) throw std::runtime_error("ERROR: wrong MCMC flag in Observable2D" + name + " at line number:" + boost::lexical_cast<std::string>(lineNo) + " of file " + infilename + ".\n");
            else sleep(2);
        }
        
        ++beg;
        setDistr(*beg);
        if (distr.compare("file") == 0) {
            if (std::distance(tok->begin(), tok->end()) < 6) {
                if(rank == 0) throw std::runtime_error("ERROR: lack of information on "+ *beg + " in " + infilename);
                else sleep (2);
            }
            setFilename(filepath + *(++beg));
            setHistoname(*(++beg));
        }

        std::vector<double> min(2, 0.);
        std::vector<double> max(2, 0.);
        std::vector<double> ave(2, 0.);
        std::vector<double> errg(2, 0.);
        std::vector<double> errf(2, 0.);
        std::vector<std::string> thname(2, "");
        std::vector<std::string> label(2, "");
        std::vector<std::string> type2D(2, "");
        std::string line;
        size_t pos = 0;
        boost::char_separator<char> sep(" \t");
        for (int i = 0; i < 2; i++) {
            IsEOF = getline(ifile, line).eof();
            if (line.empty() || line.at(0) == '#') {
                if (rank == 0) throw std::runtime_error("ERROR: no comments or empty lines in Observable2D please! In file " + infilename + " at line number:" + boost::lexical_cast<std::string>(lineNo) + ".\n");
                else sleep(2);
            }
            lineNo++;
            boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
            beg = mytok.begin();
            type2D[i] = *beg;
            if (type2D[i].compare("Observable") != 0 && type2D[i].compare("BinnedObservable") != 0 && type2D[i].compare("FunctionObservable") != 0) {
                if (rank == 0) throw std::runtime_error("ERROR: in line no." + boost::lexical_cast<std::string>(lineNo) + " of file " + infilename + ", expecting an Observable or BinnedObservable or FunctionObservable type here...\n");
                else sleep(2);
            }
            ++beg;
            thname[i] = *beg;
            ++beg;
            label[i] = *beg;
            while ((pos = label[i].find("~", pos)) != std::string::npos)
                label[i].replace(pos++, 1, " ");
            ++beg;
            min[i] = atof((*beg).c_str());
            ++beg;
            max[i] = atof((*beg).c_str());
            if (distr.compare("weight") == 0) {
                ++beg;
                ave[i] = atof((*beg).c_str());
                ++beg;
                errg[i] = atof((*beg).c_str());
                ++beg;
                errf[i] = atof((*beg).c_str());
                if (errg[i] == 0. && errg[i] == 0.) {
                    if (rank == 0) throw std::runtime_error("ERROR: The Gaussian and flat error in weight for " + name + " cannot both be 0. in the " + infilename + " file, line number:" + boost::lexical_cast<std::string>(lineNo) + ".\n");
                    else sleep(2);
                }
            } else if (distr.compare("noweight") == 0 || distr.compare("file") == 0) {
                if (type2D[i].compare("BinnedObservable") == 0 || type2D[i].compare("FunctionObservable") == 0) {
                    ++beg;
                    ++beg;
                    ++beg;
                }
            } else {
                if (rank == 0) throw std::runtime_error("ERROR: wrong distribution flag in " + name + " in file " + infilename + ".\n");
                else sleep(2);
            }
            if (type2D[i].compare("BinnedObservable") == 0) {
                ++beg;
                bin_min[i] = atof((*beg).c_str());
                ++beg;
                bin_max[i] = atof((*beg).c_str());
            } else if (type2D[i].compare("FunctionObservable") == 0) {
                ++beg;
//.........这里部分代码省略.........
开发者ID:shehu0,项目名称:HEPfitgdev,代码行数:101,代码来源:Observable2D.cpp

示例8: opendir


//.........这里部分代码省略.........
					if ( FileExists( tmpFilename.c_str() ) )
					{
						filename += *i;
						found = true;
					}
				}
			}
			std::string eventScript = std::string(getFPPDirectory()) + "/scripts/eventScript";

			if ( !found )
			{
				LogExcess(VB_PLUGIN, "No callbacks supported by plugin: '%s'\n", ep->d_name);
				continue;
			}

			LogDebug(VB_PLUGIN, "Processing Callbacks (%s) for plugin: '%s'\n", filename.c_str(), ep->d_name);

			int output_pipe[2], pid, bytes_read;
			char readbuffer[128];
			std::string callback_list = "";

			if (pipe(output_pipe) == -1)
			{
				LogErr(VB_PLUGIN, "Failed to make pipe\n");
				exit(EXIT_FAILURE);
			}

			if ((pid = fork()) == -1 )
			{
				LogErr(VB_PLUGIN, "Failed to fork\n");
				exit(EXIT_FAILURE);
			}

			if ( pid == 0 )
			{
				dup2(output_pipe[1], STDOUT_FILENO);
				close(output_pipe[1]);
				execl(eventScript.c_str(), "eventScript", filename.c_str(), "--list", NULL);

				LogErr(VB_PLUGIN, "We failed to exec our callbacks query!\n");
				exit(EXIT_FAILURE);
			}
			else
			{
				close(output_pipe[1]);

				while (true)
				{
					bytes_read = read(output_pipe[0], readbuffer, sizeof(readbuffer)-1);

					if (bytes_read <= 0)
						break;

					readbuffer[bytes_read] = '\0';
					callback_list += readbuffer;
				}

				boost::trim(callback_list);

				LogExcess(VB_PLUGIN, "Callback output: (%s)\n", callback_list.c_str());

				wait(NULL);
			}

			boost::char_separator<char> sep(",");
			boost::tokenizer< boost::char_separator<char> > tokens(callback_list, sep);
		    BOOST_FOREACH (const std::string& type, tokens)
			{
				if (type == "media")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports media callback.\n", ep->d_name);
					MediaCallback *media = new MediaCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(media);
				}
				else if (type == "playlist")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports playlist callback.\n", ep->d_name);
					PlaylistCallback *playlist = new PlaylistCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(playlist);
				}
				else if (type == "nextplaylist")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports nextplaylist callback.\n", ep->d_name);
					NextPlaylistEntryCallback *nextplaylistentry = new NextPlaylistEntryCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(nextplaylistentry);
				}
				else if (type == "event")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports event callback.\n", ep->d_name);
					EventCallback *eventcallback = new EventCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(eventcallback);
				}
			}

			plugin_count += 1;
		}
		closedir(dp);
	}
	else
	{
开发者ID:FalconChristmas,项目名称:fpp,代码行数:101,代码来源:Plugins.cpp

示例9: verbosity

Stage* Translate::makeReader(Options readerOptions)
{

    if (isDebug())
    {
        readerOptions.add<bool>("debug", true);
        boost::uint32_t verbosity(getVerboseLevel());
        if (!verbosity)
            verbosity = 1;
        
        readerOptions.add<boost::uint32_t>("verbose", verbosity);
        readerOptions.add<std::string>("log", "STDERR");
    }


    Stage* reader_stage = AppSupport::makeReader(readerOptions);
    
    Stage* final_stage(0);
    if (!m_bounds.empty() || !m_wkt.empty() || !m_output_srs.empty())
    {
        Stage* next_stage = reader_stage;
        
        Stage* crop_stage(0);
        Stage* reprojection_stage(0);

        if (!m_output_srs.empty())
        {
            readerOptions.add<std::string >("out_srs", m_output_srs.getWKT());

            boost::char_separator<char> sep(SEPARATORS);
            std::vector<double> offsets;
            tokenizer off_tokens(m_offsets, sep);
            for (tokenizer::iterator t = off_tokens.begin(); t != off_tokens.end(); ++t) {
                offsets.push_back(boost::lexical_cast<double>(*t));
            }

            std::vector<double> scales;
            tokenizer scale_tokens(m_scales, sep);
            for (tokenizer::iterator t = scale_tokens.begin(); t != scale_tokens.end(); ++t) {
                scales.push_back(boost::lexical_cast<double>(*t));
            }
            
            if (scales.size())
            {
                if (scales.size() <= 1)
                {
                    readerOptions.add<double >("scale_x", scales[0]);
                    
                }
                else if (scales.size() <= 2)
                {
                    readerOptions.add<double >("scale_x", scales[0]);
                    readerOptions.add<double >("scale_y", scales[1]);
                }
                else if (scales.size() <= 3)
                {
                    readerOptions.add<double >("scale_x", scales[0]);
                    readerOptions.add<double >("scale_y", scales[1]);
                    readerOptions.add<double >("scale_z", scales[2]);
                }
            }

            if (offsets.size())
            {
                if (offsets.size() <= 1)
                {
                    readerOptions.add<double >("offset_x", offsets[0]);
                    
                }
                else if (offsets.size() <= 2)
                {
                    readerOptions.add<double >("offset_x", offsets[0]);
                    readerOptions.add<double >("offset_y", offsets[1]);
                }
                else if (offsets.size() <= 3)
                {
                    readerOptions.add<double >("offset_x", offsets[0]);
                    readerOptions.add<double >("offset_y", offsets[1]);
                    readerOptions.add<double >("offset_z", offsets[2]);
                }
            }
            reprojection_stage = new pdal::filters::InPlaceReprojection(*next_stage, readerOptions);
            next_stage = reprojection_stage;
        }
        
        if (!m_bounds.empty() && m_wkt.empty())
        {
            readerOptions.add<pdal::Bounds<double> >("bounds", m_bounds);
            crop_stage = new pdal::filters::Crop(*next_stage, readerOptions);
            next_stage = crop_stage;
        } 
        else if (m_bounds.empty() && !m_wkt.empty())
        {
            std::istream* wkt_stream;
            try
            {
                wkt_stream = FileUtils::openFile(m_wkt);
                std::stringstream buffer;
                buffer << wkt_stream->rdbuf();

//.........这里部分代码省略.........
开发者ID:dakcarto,项目名称:PDAL,代码行数:101,代码来源:Translate.cpp

示例10: upload_pick

/**
   char* upload_pick(void* data)

   If applicable, brings up a file chooser in which the user selects a file
   to upload for a particular task.  If the file is valid for the given action,
   returns the string to the full path filename, else returns NULL.
   Data is the load filter for the type of file as defined in LLFilePicker.
**/
const std::string upload_pick(void* data)
{
 	if( gAgentCamera.cameraMouselook() )
	{
		gAgentCamera.changeCameraToDefault();
		// This doesn't seem necessary. JC
		// display();
	}

	LLFilePicker::ELoadFilter type;
	if(data)
	{
		type = (LLFilePicker::ELoadFilter)((intptr_t)data);
	}
	else
	{
		type = LLFilePicker::FFLOAD_ALL;
	}

	LLFilePicker& picker = LLFilePicker::instance();
	if (!picker.getOpenFile(type))
	{
		LL_INFOS() << "Couldn't import objects from file" << LL_ENDL;
		return std::string();
	}

	
	const std::string& filename = picker.getFirstFile();
	std::string ext = gDirUtilp->getExtension(filename);

	//strincmp doesn't like NULL pointers
	if (ext.empty())
	{
		std::string short_name = gDirUtilp->getBaseFileName(filename);
		
		// No extension
		LLSD args;
		args["FILE"] = short_name;
		LLNotificationsUtil::add("NoFileExtension", args);
		return std::string();
	}
	else
	{
		//so there is an extension
		//loop over the valid extensions and compare to see
		//if the extension is valid

		//now grab the set of valid file extensions
		std::string valid_extensions = build_extensions_string(type);

		BOOL ext_valid = FALSE;
		
		typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
		boost::char_separator<char> sep(" ");
		tokenizer tokens(valid_extensions, sep);
		tokenizer::iterator token_iter;

		//now loop over all valid file extensions
		//and compare them to the extension of the file
		//to be uploaded
		for( token_iter = tokens.begin();
			 token_iter != tokens.end() && ext_valid != TRUE;
			 ++token_iter)
		{
			const std::string& cur_token = *token_iter;

			if (cur_token == ext || cur_token == "*.*")
			{
				//valid extension
				//or the acceptable extension is any
				ext_valid = TRUE;
			}
		}//end for (loop over all tokens)

		if (ext_valid == FALSE)
		{
			//should only get here if the extension exists
			//but is invalid
			LLSD args;
			args["EXTENSION"] = ext;
			args["VALIDS"] = valid_extensions;
			LLNotificationsUtil::add("InvalidFileExtension", args);
			return std::string();
		}
	}//end else (non-null extension)

	//valid file extension
	
	//now we check to see
	//if the file is actually a valid image/sound/etc.
	if (type == LLFilePicker::FFLOAD_WAV)
	{
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Kirito,代码行数:101,代码来源:llviewermenufile.cpp

示例11: sep

  /** Using the [Post]ProcessingAlgorithm and [Post]ProcessingProperties properties,
   * create and initialize an algorithm for processing.
   *
   * @param postProcessing :: true to create the PostProcessingAlgorithm.
   *        false to create the ProcessingAlgorithm
   * @return shared pointer to the algorithm, ready for execution.
   *         Returns a NULL pointer if no algorithm was chosen.
   */
  IAlgorithm_sptr LiveDataAlgorithm::makeAlgorithm(bool postProcessing)
  {
    std::string prefix = "";
    if (postProcessing)
      prefix = "Post";

    // Get the name of the algorithm to run
    std::string algoName = this->getPropertyValue(prefix+"ProcessingAlgorithm");
    algoName = Strings::strip(algoName);

    // Get the script to run. Ignored if algo is specified
    std::string script = this->getPropertyValue(prefix+"ProcessingScript");
    script = Strings::strip(script);

    if (!algoName.empty())
    {
      // Properties to pass to algo
      std::string props = this->getPropertyValue(prefix+"ProcessingProperties");

      // Create the UNMANAGED algorithm
      IAlgorithm_sptr alg = this->createChildAlgorithm(algoName);

      // ...and pass it the properties
      boost::char_separator<char> sep(";");
      typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
      tokenizer propPairs(props, sep);
      // Iterate over the properties
      for (tokenizer::iterator it = propPairs.begin(); it != propPairs.end(); ++it)
      {
        // Pair of the type "
        std::string pair = *it;

        size_t n = pair.find('=');
        if (n == std::string::npos)
        {
          // Do nothing
        }
        else
        {
          // Normal "PropertyName=value" string.
          std::string propName = "";
          std::string value = "";

          // Extract the value string
          if (n < pair.size()-1)
          {
            propName = pair.substr(0, n);
            value = pair.substr(n+1, pair.size()-n-1);
          }
          else
          {
            // String is "PropertyName="
            propName = pair.substr(0, n);
            value = "";
          }
          // Skip some of the properties when setting
          if ((propName != "InputWorkspace") && (propName != "OutputWorkspace"))
            alg->setPropertyValue(propName,value);
        }
      }

      // Warn if someone put both values.
      if (!script.empty())
        g_log.warning() << "Running algorithm " << algoName << " and ignoring the script code in " << prefix+"ProcessingScript" << std::endl;
      return alg;
    }
    else if (!script.empty())
    {
      // Run a snippet of python
      IAlgorithm_sptr alg = this->createChildAlgorithm("RunPythonScript");
      alg->setLogging(false);
      alg->setPropertyValue("Code", script);
      return alg;
    }
    else
      return IAlgorithm_sptr();
  }
开发者ID:trnielsen,项目名称:mantid,代码行数:85,代码来源:LiveDataAlgorithm.cpp

示例12: regexSelectPnWithNumPattern

/*
 * データベース管理実行
 */
void ManageRecordedDataOnMySQL::run()
{
	try
	{
		typedef boost::char_separator<char> BOOST_CHAR_SEP;
		typedef boost::tokenizer< BOOST_CHAR_SEP > BOOST_TOKENIZER;

		boost::regex regexSelectPnPattern       ("select pn");
		boost::regex regexSelectPnWithNumPattern("select pn +[0-9]{1,9}");
		boost::regex regexSelectImPattern       ("select im");
		boost::regex regexSelectImWithNumPattern("select im +[0-9]{1,9}");
		boost::regex regexUpdateMidPattern      ("update pn +[0-9]{1,9} +[0-9]{1,9}");
		//boost::regex regexUpdateMidPattern      ("update pn +[0-9]{1,9} +rid +[0-9]{1,9}");
		//boost::regex regexUpdateMemoPattern     ("update pn +[0-9]{1,9} +memo .+");
		boost::regex regexDeletePattern         ("delete pn +[0-9]{1,9}");
		boost::regex regexHelpPattern           ("h");
		boost::regex regexExitPattern           ("q");

		DatabaseDAO databaseDAO;

		char inputLineAry[DatabaseDAO::MAX_LINE];
		BOOST_CHAR_SEP sep(" ");

		std::string inputLine;

		// 使い方表示
		this->printHelp();

		while (true)
		{
			std::cout << std::endl;
			std::cout << "> コマンドを入力してください(h :help)" << std::endl;
			std::cout << "> "; std::cin.getline(inputLineAry, DatabaseDAO::MAX_LINE);

			std::string inputLine = inputLineAry;

			boost::algorithm::trim(inputLine);

			/*
			 * select pn
			 */
			if (regex_match(inputLine, regexSelectPnPattern))
			{
				databaseDAO.select();
			}
			/*
			 * select pn XXX
			 */
			else if (regex_match(inputLine, regexSelectPnWithNumPattern))
			{
				BOOST_TOKENIZER tokens(inputLine, sep);
				boost::tokenizer< BOOST_CHAR_SEP >::iterator it = tokens.begin();

				it++; it++;
				int printNum = stoi(*it);

				databaseDAO.select(printNum);
			}
			/*
			 * select im
			 */
			else if (regex_match(inputLine, regexSelectImPattern))
			{
				databaseDAO.selectImitation();
			}
			/*
			 * select im XXX
			 */
			else if (regex_match(inputLine, regexSelectImWithNumPattern))
			{
				BOOST_TOKENIZER tokens(inputLine, sep);
				boost::tokenizer< BOOST_CHAR_SEP >::iterator it = tokens.begin();

				it++; it++;
				int printNum = stoi(*it);

				databaseDAO.selectImitation(printNum);
			}
			/*
			 * update pn RRR NNN
			 */
			else if (regex_match(inputLine, regexUpdateMidPattern))
			{
				BOOST_TOKENIZER tokens(inputLine, sep);
				boost::tokenizer< BOOST_CHAR_SEP >::iterator it = tokens.begin();

				it++; it++;
				std::string recId = *it;
				it++; 
				std::string newRecId = *it;

				// 事前エラーチェック
				if (databaseDAO.selectCount(DatabaseDAO::SUMMARY_TBL, "rec_id", recId) == 0)
				{
					std::cout << "更新元のrec_id(" + recId + ")が存在しません。処理終了します。" << std::endl;
					continue;
				}
//.........这里部分代码省略.........
开发者ID:t-inamura,项目名称:EmbodiedBrain,代码行数:101,代码来源:manage_recorded_data_on_mysql.cpp

示例13: ifs

bool Map::loadMap(std::string file, Player *player)
{
	int i,e;
	std::string linha; // temp
	
	Console::printf("Comecar a ler o ficheiro do mapa %s",file.c_str());
	
	std::ifstream ifs (file.c_str(), std::ios::in);
	if (ifs.fail ())
		return false;
	
	// ler tamanho
	ifs >> this->tamanho_mapa;
	
	// ler textura do tecto
	ifs >> this->tex_tecto;
	
	// ler textura do chao
	ifs >> this->tex_chao;
	
	// portas para a fisica, vamos por tudo a 0, as portas tem de falar ah fisica para actualizar o seu estado
	std::vector<std::vector <bool> > to_fisica_portas(this->tamanho_mapa, std::vector<bool>(this->tamanho_mapa));
	std::vector<std::vector <bool> > to_fisica_objectos(this->tamanho_mapa, std::vector<bool>(this->tamanho_mapa));
	std::vector<std::vector <bool> > fisica_guardas(this->tamanho_mapa, std::vector<bool>(this->tamanho_mapa));
	for(int i=0; i<to_fisica_portas.size(); i++)
		for(int e=0; e<to_fisica_portas.size(); e++){
			to_fisica_portas[i][e] = true;
			to_fisica_objectos[i][e] = false;
			fisica_guardas[i][e] = false;
		}
	Fisica::setGuardas(fisica_guardas);
	
	std::getline (ifs, linha);
	boost::char_separator<char> sep(",");
    for(i=0; i<this->tamanho_mapa; i++)
	{
		std::vector<int> codigos_mapa(this->tamanho_mapa-1);
		std::vector<int> linha_para_ir(this->tamanho_mapa-1);
		std::getline (ifs, linha);
		Tokenize(linha, codigos_mapa ,sep);
		linha_para_ir.clear();
		for(e=0; e<codigos_mapa.size(); e++){
			// stuff pro mapa
			//	1000 - texturas
			//	2000 - guardas
			//  3000 - portas
			//  4000 - items
			//  5000 - objectos mapa
			bool to_go = true;
			if(codigos_mapa[e]>1000 && codigos_mapa[e]<2000){
				// paredes -> enviar para o 
				linha_para_ir.push_back(codigos_mapa[e]);
				to_go = false;
			}else
			if(codigos_mapa[e]>3000 && codigos_mapa[e]<4000){
				// portas
				switch(codigos_mapa[e]){
					case 3001:
						// porta norte-sul
						this->addPorta(i,e,0, 0);
						break;
					case 3002:
						// porta oeste-este
						this->addPorta(i,e,0, 1);
						break;	
					case 3003:
						// porta norte-sul chave amarela
						this->addPorta(i,e,1, 0);
						break;
					case 3004:
						// porta oeste-este chave amarela
						this->addPorta(i,e,1, 1);
						break;
					case 3005:
						// porta norte-sul chave vermelha
						this->addPorta(i,e,2, 0);
						break;
					case 3006:
						// porta oeste-este chave vermelha
						this->addPorta(i,e,2, 1);
						break;
					default:
						Console::printf("Nao entendo este codigo de mapa porta: %d",codigos_mapa[e]);
						break;
				}
				if(codigos_mapa[e]>=3001 && codigos_mapa[e]<=3006){
					to_fisica_portas[i][e]=false;
				}
				
			}else
			if(codigos_mapa[e]>4000 && codigos_mapa[e]<5000){
				// items
				switch(codigos_mapa[e]){
					case 4001:
						// vida 15
						this->addItems(i,e,1);
						break;
					case 4002:
						// vida 25
						this->addItems(i,e,2);
//.........这里部分代码省略.........
开发者ID:zipleen,项目名称:space-wolf,代码行数:101,代码来源:map.cpp

示例14: sep

/* texturas */
bool Map::loadTextures()
{
	std::string line;
	boost::char_separator<char> sep(" ");
	Console::addLine("Loading textures...");
	std::ifstream ifs ("data/textures/textures.def", std::ios::in);
	if (ifs.fail ()){
		Console::addLine("Erro a ler o ficheiro de texturas");
		return false;
	}
	
	// fazer o mapa das texturas que sao necessarias
	std::set<int> needed;
	for(int i=0; i< this->map.size(); ++i)
	{
		for(int e=0; e< this->map[i].size(); ++e){
			
		if(this->map[i][e]!=0)
			needed.insert(this->map[i][e]);
		}
	}
	needed.insert(this->tex_chao);
	needed.insert(this->tex_tecto);
	needed.insert(this->tex_porta);
	needed.insert(this->tex_porta_lado);
	needed.insert(this->tex_porta_chave1);
	needed.insert(this->tex_porta_lado_chave1);
	needed.insert(this->tex_porta_chave2);
	needed.insert(this->tex_porta_lado_chave2);
	
	while(!ifs.eof())
	{
		std::vector<std::string> t;
		int num;
		// ler linha
		std::getline(ifs, line);
		if(line.size()>1){
			// partir pq o primeiro eh o numero e segundo eh a path
			Tokenize(line, t, sep);
			num = StrtoInt(t[0]);
			// iterador para encontrar no needed
			set<int>::iterator it;
			it=needed.find(num);
			if(it!=needed.end()){
				Console::addLine("Loading texture "+t[0]+" in "+t[1]);
				Texture2D *tex = this->texMgr->load (t[1]);
				this->map_textures.insert (TexMap::value_type (num, tex));
			}
		}
	}
	
	// buscar texturas de portas
	this->textura_porta = this->map_textures.find(this->tex_porta)->second;
	this->textura_porta_lado = this->map_textures.find (this->tex_porta_lado)->second;
	this->textura_porta_chave1 = this->map_textures.find (this->tex_porta_chave1)->second;
	this->textura_porta_lado_chave1 = this->map_textures.find (this->tex_porta_lado_chave1)->second;
	this->textura_porta_chave2 = this->map_textures.find(this->tex_porta_chave2)->second;
	this->textura_porta_lado_chave2 = this->map_textures.find (this->tex_porta_lado_chave2)->second;
	
	Console::addLine("Ended loading textures");
	
	Console::addLine("Generating CallLists");
	this->createCallListMap();
	Console::addLine("Generating CallLists completed");
	return true;
}
开发者ID:zipleen,项目名称:space-wolf,代码行数:67,代码来源:map.cpp

示例15: main

int main(int argc, const char* argv[])
{
	puts("usage: asio_client [link num=1]");
	if (argc > 1)
		link_num = std::min(256, std::max(atoi(argv[1]), 1));

	puts("\nthis is a file client.");
	puts("type quit to end this client.");

	std::string str;
	st_service_pump service_pump;
	file_client client(service_pump);
	for (int i = 0; i < link_num; ++i)
	{
		BOOST_AUTO(client_ptr, client.create_client());
//		client_ptr->set_server_addr(SERVER_PORT, "::1"); //ipv6
//		client_ptr->set_server_addr(SERVER_PORT, "127.0.0.1"); //ipv4
		client_ptr->set_index(i);
		client.add_client(client_ptr);
	}

	service_pump.start_service();
	while(service_pump.is_running())
	{
		std::getline(std::cin, str);
		if (str == QUIT_COMMAND)
			service_pump.stop_service();
		else if (str == RESTART_COMMAND)
		{
			service_pump.stop_service();
			service_pump.start_service();
		}
		else if (str.size() > sizeof(REQUEST_FILE) &&
			!strncmp(REQUEST_FILE, str.data(), sizeof(REQUEST_FILE) - 1) &&
			isspace(str[sizeof(REQUEST_FILE) - 1]))
		{
			str.erase(0, sizeof(REQUEST_FILE));
			boost::char_separator<char> sep(" \t");
			boost::tokenizer<boost::char_separator<char> > tok(str, sep);
			for (BOOST_AUTO(iter, tok.begin()); iter != tok.end(); ++iter)
			{
				completed_client_num.store(0);
				file_size = 0;
				int begin_time = boost::get_system_time().time_of_day().total_seconds();
				if (client.at(0)->get_file(*iter))
				{
					for (int i = 1; i < link_num; ++i)
						client.at(i)->get_file(*iter);

					printf("transfer %s begin.\n", iter->data());
					unsigned percent = -1;
					while (completed_client_num.load() != (unsigned short) link_num)
					{
						boost::this_thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(50));
						if (file_size > 0)
						{
							__off64_t total_rest_size = client.get_total_rest_size();
							if (total_rest_size > 0)
							{
								unsigned new_percent =
									(unsigned) ((file_size - total_rest_size) * 100 / file_size);
								if (percent != new_percent)
								{
									percent = new_percent;
									printf("\r%u%%", percent);
									fflush(stdout);
								}
							}
						}
					}
					int used_time = boost::get_system_time().time_of_day().total_seconds() - begin_time;
					if (used_time > 0)
						printf("\r100%%\ntransfer %s end, speed: " __off64_t_format "kB/s.\n",
							iter->data(), file_size / 1024 / used_time);
					else
						printf("\r100%%\ntransfer %s end.\n", iter->data());
				}
			}
		}
		else
			client.at(0)->talk(str);
	}

	return 0;
}
开发者ID:luyinquan,项目名称:st_asio_wrapper,代码行数:85,代码来源:file_client.cpp


注:本文中的sep函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。