您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tokenizer函数代码示例

51自学网 2021-06-03 08:55:05
  C++
这篇教程C++ tokenizer函数代码示例写得很实用,希望能帮到您。

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

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

示例1: SendTooltipMessage

bool wxToolTip::AdjustMaxWidth(){    // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the    // extent of its first line as max value    HFONT hfont = (HFONT)        SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0);    if ( !hfont )    {        hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);        if ( !hfont )        {            wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)"));        }    }    MemoryHDC hdc;    if ( !hdc )    {        wxLogLastError(wxT("CreateCompatibleDC(NULL)"));    }    if ( !SelectObject(hdc, hfont) )    {        wxLogLastError(wxT("SelectObject(hfont)"));    }    // find the width of the widest line    int maxWidth = 0;    wxStringTokenizer tokenizer(m_text, wxT("/n"));    while ( tokenizer.HasMoreTokens() )    {        const wxString token = tokenizer.GetNextToken();        SIZE sz;        if ( !::GetTextExtentPoint32(hdc, token.t_str(),                                     token.length(), &sz) )        {            wxLogLastError(wxT("GetTextExtentPoint32"));        }        if ( sz.cx > maxWidth )            maxWidth = sz.cx;    }    // limit size to ms_maxWidth, if set    if ( ms_maxWidth == 0 )    {        // this is more or less arbitrary but seems to work well        static const int DEFAULT_MAX_WIDTH = 400;        ms_maxWidth = wxGetClientDisplayRect().width / 2;        if ( ms_maxWidth > DEFAULT_MAX_WIDTH )            ms_maxWidth = DEFAULT_MAX_WIDTH;    }    if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth )        maxWidth = ms_maxWidth;    // only set a new width if it is bigger than the current setting:    // otherwise adding a tooltip with shorter line(s) than a previous    // one would result in breaking the longer lines unnecessarily as    // all our tooltips share the same maximal width    if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(),                                       TTM_GETMAXTIPWIDTH, 0) )    {        SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,                           wxUIntToPtr(maxWidth));    }    return true;}
开发者ID:Asmodean-,项目名称:Ishiiruka,代码行数:73,


示例2: memset

/** * _ccs_get_xpathlite * @handle: * @connection_handle: * @query: * @list: 1 to operate in list fashion * * This function will allocate space for the value that is the result * of the given query.  It is the user's responsibility to ensure that * the data returned is freed. * * Returns: char * to result or NULL in case of failure. */char *_ccs_get_xpathlite(confdb_handle_t handle, hdb_handle_t connection_handle,			 const char *query, int list){	char current_query[PATH_MAX];	char *datapos, *rtn = NULL;	char previous_query[PATH_MAX];	hdb_handle_t list_handle = 0;	hdb_handle_t query_handle = 0;	int prev = 0, is_oldlist = 0;	int tokens, i;	memset(current_query, 0, PATH_MAX);	strncpy(current_query, query, PATH_MAX - 1);	memset(previous_query, 0, PATH_MAX);	datapos = current_query + 1;	prev =	    get_previous_query(handle, connection_handle, previous_query,			       &list_handle);	if (list && !prev && !strcmp(current_query, previous_query)) {		query_handle = list_handle;		is_oldlist = 1;	} else {		reset_iterator(handle, connection_handle);		query_handle = OBJECT_PARENT_HANDLE;	}	if (confdb_object_find_start(handle, query_handle) != CS_OK) {		errno = ENOENT;		goto fail;	}	tokens = tokenizer(current_query);	if (tokens < 1)		goto fail;	for (i = 1; i < tokens; i++)		datapos = datapos + strlen(datapos) + 1;	if (!is_oldlist)		if (path_dive(handle, &query_handle, current_query, tokens - 1) < 0)	/* path dive can mangle tokens */			goto fail;	if (get_data	    (handle, connection_handle, query_handle, &list_handle, &rtn,	     datapos, list, is_oldlist) < 0)		goto fail;	if (list)		if (set_previous_query		    (handle, connection_handle, (char *)query, list_handle))			goto fail;	return rtn;fail:	return NULL;}
开发者ID:smintz,项目名称:cluster,代码行数:74,


示例3: wxLoadQueryNearestFont

wxNativeFont wxLoadQueryNearestFont(int pointSize,                                    int family,                                    int style,                                    int weight,                                    bool underlined,                                    const wxString &facename,                                    wxFontEncoding encoding,                                    wxString* xFontName){    if ( encoding == wxFONTENCODING_DEFAULT )    {        encoding = wxFont::GetDefaultEncoding();    }    // first determine the encoding - if the font doesn't exist at all in this    // encoding, it's useless to do all other approximations (i.e. size,    // family &c don't matter much)    wxNativeEncodingInfo info;    if ( encoding == wxFONTENCODING_SYSTEM )    {        // This will always work so we don't test to save time        wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info);    }    else    {        if ( !wxGetNativeFontEncoding(encoding, &info) ||             !wxTestFontEncoding(info) )        {#if wxUSE_FONTMAP            if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )#endif // wxUSE_FONTMAP            {                // unspported encoding - replace it with the default                //                // NB: we can't just return 0 from here because wxGTK code doesn't                //     check for it (i.e. it supposes that we'll always succeed),                //     so it would provoke a crash                wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info);            }        }    }    // OK, we have the correct xregistry/xencoding in info structure    wxNativeFont font = 0;    // if we already have the X font name, try to use it    if( xFontName && !xFontName->empty() )    {        //        //  Make sure point size is correct for scale factor.        //        wxStringTokenizer tokenizer(*xFontName, wxT("-"), wxTOKEN_RET_DELIMS);        wxString newFontName;        for(int i = 0; i < 8; i++)          newFontName += tokenizer.NextToken();        (void) tokenizer.NextToken();        newFontName += wxString::Format(wxT("%d-"), pointSize);        while(tokenizer.HasMoreTokens())          newFontName += tokenizer.GetNextToken();        font = wxLoadFont(newFontName);        if(font)          *xFontName = newFontName;    }    if ( !font )    {        // search up and down by stepsize 10        int max_size = pointSize + 20 * (1 + (pointSize/180));        int min_size = pointSize - 20 * (1 + (pointSize/180));        int i, round; // counters        // first round: search for equal, then for smaller and for larger size        // with the given weight and style        int testweight = weight;        int teststyle = style;        for ( round = 0; round < 3; round++ )        {            // second round: use normal weight            if ( round == 1 )            {                if ( testweight != wxNORMAL )                {                    testweight = wxNORMAL;                }                else                {                    ++round; // fall through to third round                }            }            // third round: ... and use normal style            if ( round == 2 )//.........这里部分代码省略.........
开发者ID:beanhome,项目名称:dev,代码行数:101,


示例4: compute_envelope

void compute_envelope(const scorer_document_type& scorers,		      const hypergraph_set_type&  graphs,		      const weight_set_type& origin,		      const weight_set_type& direction,		      segment_document_type& segments){  typedef utils::mpi_device_source idevice_type;  typedef utils::mpi_device_sink   odevice_type;    typedef boost::iostreams::filtering_ostream ostream_type;  typedef boost::iostreams::filtering_istream istream_type;  typedef boost::tokenizer<utils::space_separator, utils::piece::const_iterator, utils::piece> tokenizer_type;  typedef EnvelopeTask task_type;  typedef task_type::queue_type queue_type;    const int mpi_rank = MPI::COMM_WORLD.Get_rank();  const int mpi_size = MPI::COMM_WORLD.Get_size();    queue_type queue;    boost::thread worker(task_type(queue, segments, origin, direction, scorers, graphs));    for (size_t seg = 0; seg != graphs.size(); ++ seg)    if (graphs[seg].is_valid())      queue.push(seg);  queue.push(-1);    worker.join();    // merge segments into root  if (mpi_rank == 0) {    for (int rank = 1; rank != mpi_size; ++ rank) {      istream_type is;      is.push(boost::iostreams::zlib_decompressor());      is.push(idevice_type(rank, envelope_tag, 4096));            std::string line;      while (std::getline(is, line)) {	const utils::piece line_piece(line);	tokenizer_type tokenizer(line_piece);		tokenizer_type::iterator iter = tokenizer.begin();	if (iter == tokenizer.end()) continue;	const utils::piece id_str = *iter; 		++ iter;	if (iter == tokenizer.end() || *iter != "|||") continue;		++ iter;	if (iter == tokenizer.end()) continue;	const utils::piece x_str = *iter;		++ iter;	if (iter == tokenizer.end() || *iter != "|||") continue;		++ iter;	if (iter == tokenizer.end()) continue;	const utils::piece score_str = *iter;		const int id = utils::lexical_cast<int>(id_str);		if (id >= static_cast<int>(segments.size()))	  throw std::runtime_error("invali id?");		segments[id].push_back(std::make_pair(utils::decode_base64<double>(x_str),					      scorer_type::score_type::decode(score_str)));      }    }      } else {    ostream_type os;    os.push(boost::iostreams::zlib_compressor());    os.push(odevice_type(0, envelope_tag, 4096));        for (size_t seg = 0; seg != segments.size(); ++ seg)      if (! segments[seg].empty()) {	segment_set_type::const_iterator siter_end = segments[seg].end();	for (segment_set_type::const_iterator siter = segments[seg].begin(); siter != siter_end; ++ siter) {	  os << seg << " ||| ";	  utils::encode_base64(siter->x, std::ostream_iterator<char>(os));	  os << " ||| " << siter->score->encode()	     << '/n';	}      }  }}
开发者ID:hitochan777,项目名称:cicada,代码行数:90,


示例5: main

int main( int argc, const char* argv[]){	int rt = 0;	std::auto_ptr<strus::ErrorBufferInterface> errorBuffer( strus::createErrorBuffer_standard( 0, 2));	if (!errorBuffer.get())	{		std::cerr << _TXT("failed to create error buffer") << std::endl;		return -1;	}	strus::ProgramOptions opt;	bool printUsageAndExit = false;	try	{		opt = strus::ProgramOptions(				argc, argv, 11,				"h,help", "v,version", "license", "t,tokenizer:", "n,normalizer:",				"m,module:", "M,moduledir:", "q,quot:", "p,plain",				"R,resourcedir:", "T,trace:");		if (opt( "help")) printUsageAndExit = true;		std::auto_ptr<strus::ModuleLoaderInterface> moduleLoader( strus::createModuleLoader( errorBuffer.get()));		if (!moduleLoader.get()) throw strus::runtime_error(_TXT("failed to create module loader"));		if (opt("moduledir"))		{			std::vector<std::string> modirlist( opt.list("moduledir"));			std::vector<std::string>::const_iterator mi = modirlist.begin(), me = modirlist.end();			for (; mi != me; ++mi)			{				moduleLoader->addModulePath( *mi);			}			moduleLoader->addSystemModulePath();		}		if (opt("module"))		{			std::vector<std::string> modlist( opt.list("module"));			std::vector<std::string>::const_iterator mi = modlist.begin(), me = modlist.end();			for (; mi != me; ++mi)			{				if (!moduleLoader->loadModule( *mi))				{					throw strus::runtime_error(_TXT("error failed to load module %s"), mi->c_str());				}			}		}		if (opt("license"))		{			std::vector<std::string> licenses_3rdParty = moduleLoader->get3rdPartyLicenseTexts();			std::vector<std::string>::const_iterator ti = licenses_3rdParty.begin(), te = licenses_3rdParty.end();			if (ti != te) std::cout << _TXT("3rd party licenses:") << std::endl;			for (; ti != te; ++ti)			{				std::cout << *ti << std::endl;			}			std::cerr << std::endl;			if (!printUsageAndExit) return 0;		}		if (opt( "version"))		{			std::cout << _TXT("Strus utilities version ") << STRUS_UTILITIES_VERSION_STRING << std::endl;			std::cout << _TXT("Strus module version ") << STRUS_MODULE_VERSION_STRING << std::endl;			std::cout << _TXT("Strus rpc version ") << STRUS_RPC_VERSION_STRING << std::endl;			std::cout << _TXT("Strus trace version ") << STRUS_TRACE_VERSION_STRING << std::endl;			std::cout << _TXT("Strus analyzer version ") << STRUS_ANALYZER_VERSION_STRING << std::endl;			std::cout << _TXT("Strus base version ") << STRUS_BASE_VERSION_STRING << std::endl;			std::vector<std::string> versions_3rdParty = moduleLoader->get3rdPartyVersionTexts();			std::vector<std::string>::const_iterator vi = versions_3rdParty.begin(), ve = versions_3rdParty.end();			if (vi != ve) std::cout << _TXT("3rd party versions:") << std::endl;			for (; vi != ve; ++vi)			{				std::cout << *vi << std::endl;			}			if (!printUsageAndExit) return 0;		}		else if (!printUsageAndExit)		{			if (opt.nofargs() > 1)			{				std::cerr << _TXT("too many arguments") << std::endl;				printUsageAndExit = true;				rt = 1;			}			if (opt.nofargs() < 1)			{				std::cerr << _TXT("too few arguments") << std::endl;				printUsageAndExit = true;				rt = 2;			}		}		if (printUsageAndExit)		{			std::cout << _TXT("usage:") << " strusAnalyze [options] <phrasepath>" << std::endl;			std::cout << "<phrasepath> = " << _TXT("path to phrase to analyze ('-' for stdin)") << std::endl;			std::cout << "description: " << _TXT("tokenizes and normalizes a text segment") << std::endl;			std::cout << "             " << _TXT("and prints the result to stdout.") << std::endl;			std::cout << _TXT("options:") << std::endl;			std::cout << "-h|--help" << std::endl;			std::cout << "   " << _TXT("Print this usage and do nothing else") << std::endl;			std::cout << "-v|--version" << std::endl;			std::cout << "    " << _TXT("Print the program version and do nothing else") << std::endl;			std::cout << "--license" << std::endl;//.........这里部分代码省略.........
开发者ID:andreasbaumann,项目名称:strusUtilities,代码行数:101,


示例6: GetMediaPluginHost

/* static */CanPlayStatusDecoderTraits::CanHandleMediaType(const char* aMIMEType,                                  bool aHaveRequestedCodecs,                                  const nsAString& aRequestedCodecs){  char const* const* codecList = nullptr;  CanPlayStatus result = CANPLAY_NO;#ifdef MOZ_RAW  if (IsRawType(nsDependentCString(aMIMEType))) {    codecList = gRawCodecs;    result = CANPLAY_MAYBE;  }#endif#ifdef MOZ_OGG  if (IsOggType(nsDependentCString(aMIMEType))) {    codecList = MediaDecoder::IsOpusEnabled() ? gOggCodecsWithOpus : gOggCodecs;    result = CANPLAY_MAYBE;  }#endif#ifdef MOZ_WAVE  if (IsWaveType(nsDependentCString(aMIMEType))) {    codecList = gWaveCodecs;    result = CANPLAY_MAYBE;  }#endif#ifdef MOZ_WEBM  if (IsWebMType(nsDependentCString(aMIMEType))) {    codecList = gWebMCodecs;    result = CANPLAY_YES;  }#endif#ifdef MOZ_DASH  if (IsDASHMPDType(nsDependentCString(aMIMEType))) {    // DASH manifest uses WebM codecs only.    codecList = gWebMCodecs;    result = CANPLAY_YES;  }#endif#ifdef MOZ_GSTREAMER  if (GStreamerDecoder::CanHandleMediaType(nsDependentCString(aMIMEType),                                           aHaveRequestedCodecs ? &aRequestedCodecs : nullptr)) {    if (aHaveRequestedCodecs)      return CANPLAY_YES;    return CANPLAY_MAYBE;  }#endif#ifdef MOZ_OMX_DECODER  if (IsOmxSupportedType(nsDependentCString(aMIMEType))) {    result = CANPLAY_MAYBE;    if (nsDependentCString(aMIMEType).EqualsASCII("audio/mpeg")) {      codecList = gMpegAudioCodecs;    } else {      codecList = gH264Codecs;    }  }#endif#ifdef MOZ_WMF  if (WMFDecoder::GetSupportedCodecs(nsDependentCString(aMIMEType), &codecList)) {    result = CANPLAY_MAYBE;  }#endif#ifdef MOZ_DIRECTSHOW  if (DirectShowDecoder::GetSupportedCodecs(nsDependentCString(aMIMEType), &codecList)) {    result = CANPLAY_MAYBE;  }#endif#ifdef MOZ_APPLEMEDIA  if (IsAppleMediaSupportedType(nsDependentCString(aMIMEType), &codecList)) {    result = CANPLAY_MAYBE;  }#endif#ifdef MOZ_MEDIA_PLUGINS  if (MediaDecoder::IsMediaPluginsEnabled() &&      GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), &codecList))    result = CANPLAY_MAYBE;#endif  if (result == CANPLAY_NO || !aHaveRequestedCodecs || !codecList) {    return result;  }  // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description  // of the 'codecs' parameter  nsCharSeparatedTokenizer tokenizer(aRequestedCodecs, ',');  bool expectMoreTokens = false;  while (tokenizer.hasMoreTokens()) {    const nsSubstring& token = tokenizer.nextToken();    if (!CodecListContains(codecList, token)) {      // Totally unsupported codec      return CANPLAY_NO;    }    expectMoreTokens = tokenizer.lastTokenEndedWithSeparator();  }  if (expectMoreTokens) {    // Last codec name was empty    return CANPLAY_NO;  }  return CANPLAY_YES;}
开发者ID:jsyeo,项目名称:mozilla-central,代码行数:100,


示例7: reset

void Context::initialize(ContextType contextType) {	// Initialize default state.	reset();	type = contextType;	// Obtain maximum texture size.	glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&maxTextureSize);	debug(5, "OpenGL maximum texture size: %d", maxTextureSize);	const char *extString = (const char *)glGetString(GL_EXTENSIONS);	bool ARBShaderObjects = false;	bool ARBShadingLanguage100 = false;	bool ARBVertexShader = false;	bool ARBFragmentShader = false;	bool EXTFramebufferMultisample = false;	bool EXTFramebufferBlit = false;	Common::StringTokenizer tokenizer(extString, " ");	while (!tokenizer.empty()) {		Common::String token = tokenizer.nextToken();		if (token == "GL_ARB_texture_non_power_of_two" || token == "GL_OES_texture_npot") {			NPOTSupported = true;		} else if (token == "GL_ARB_shader_objects") {			ARBShaderObjects = true;		} else if (token == "GL_ARB_shading_language_100") {			ARBShadingLanguage100 = true;		} else if (token == "GL_ARB_vertex_shader") {			ARBVertexShader = true;		} else if (token == "GL_ARB_fragment_shader") {			ARBFragmentShader = true;		} else if (token == "GL_EXT_framebuffer_object") {			framebufferObjectSupported = true;		} else if (token == "GL_EXT_packed_depth_stencil" || token == "GL_OES_packed_depth_stencil") {			packedDepthStencilSupported = true;		} else if (token == "GL_EXT_unpack_subimage") {			unpackSubImageSupported = true;		} else if (token == "GL_EXT_framebuffer_multisample") {			EXTFramebufferMultisample = true;		} else if (token == "GL_EXT_framebuffer_blit") {			EXTFramebufferBlit = true;		} else if (token == "GL_OES_depth24") {			OESDepth24 = true;		}			}	int glslVersion = getGLSLVersion();	debug(5, "OpenGL GLSL version: %d", glslVersion);	if (type == kContextGLES2) {		// GLES2 always has (limited) NPOT support.		NPOTSupported = true;		// GLES2 always has shader support.		shadersSupported = true;		// GLES2 always has FBO support.		framebufferObjectSupported = true;		// ResidualVM does not support multisample FBOs with GLES2 for now		framebufferObjectMultisampleSupported = false;		multisampleMaxSamples = -1;	} else {		shadersSupported = ARBShaderObjects && ARBShadingLanguage100 && ARBVertexShader && ARBFragmentShader && glslVersion >= 120;		// Desktop GL always has unpack sub-image support		unpackSubImageSupported = true;		framebufferObjectMultisampleSupported = EXTFramebufferMultisample && EXTFramebufferBlit;		if (framebufferObjectMultisampleSupported) {			glGetIntegerv(GL_MAX_SAMPLES, (GLint *)&multisampleMaxSamples);		}	}	// Log context type.	switch (type) {		case kContextGL:			debug(5, "OpenGL: GL context initialized");			break;		case kContextGLES2:			debug(5, "OpenGL: GLES2 context initialized");			break;	}	// Log features supported by GL context.	debug(5, "OpenGL: NPOT texture support: %d", NPOTSupported);	debug(5, "OpenGL: Shader support: %d", shadersSupported);	debug(5, "OpenGL: FBO support: %d", framebufferObjectSupported);	debug(5, "OpenGL: Packed depth stencil support: %d", packedDepthStencilSupported);	debug(5, "OpenGL: Unpack subimage support: %d", unpackSubImageSupported);}
开发者ID:DouglasLiuGamer,项目名称:residualvm,代码行数:96,


示例8: parseVariableName

std::string parseVariableName (const char* nameWithPath){	VarTokenizer tokenizer(nameWithPath);	TCU_CHECK(tokenizer.getToken() == VarTokenizer::TOKEN_IDENTIFIER);	return tokenizer.getIdentifier();}
开发者ID:MIPS,项目名称:external-deqp,代码行数:6,


示例9: parseTypePath

void parseTypePath (const char* nameWithPath, const VarType& type, TypeComponentVector& path){	VarTokenizer tokenizer(nameWithPath);	if (tokenizer.getToken() == VarTokenizer::TOKEN_IDENTIFIER)		tokenizer.advance();	path.clear();	while (tokenizer.getToken() != VarTokenizer::TOKEN_END)	{		VarType curType = getVarType(type, path);		if (tokenizer.getToken() == VarTokenizer::TOKEN_PERIOD)		{			tokenizer.advance();			TCU_CHECK(tokenizer.getToken() == VarTokenizer::TOKEN_IDENTIFIER);			TCU_CHECK_MSG(curType.isStructType(), "Invalid field selector");			// Find member.			std::string		memberName	= tokenizer.getIdentifier();			int				ndx			= 0;			for (; ndx < curType.getStructPtr()->getNumMembers(); ndx++)			{				if (memberName == curType.getStructPtr()->getMember(ndx).getName())					break;			}			TCU_CHECK_MSG(ndx < curType.getStructPtr()->getNumMembers(), "Member not found in type");			path.push_back(VarTypeComponent(VarTypeComponent::STRUCT_MEMBER, ndx));			tokenizer.advance();		}		else if (tokenizer.getToken() == VarTokenizer::TOKEN_LEFT_BRACKET)		{			tokenizer.advance();			TCU_CHECK(tokenizer.getToken() == VarTokenizer::TOKEN_NUMBER);			int ndx = tokenizer.getNumber();			if (curType.isArrayType())			{				TCU_CHECK(de::inBounds(ndx, 0, curType.getArraySize()));				path.push_back(VarTypeComponent(VarTypeComponent::ARRAY_ELEMENT, ndx));			}			else if (curType.isBasicType() && isDataTypeMatrix(curType.getBasicType()))			{				TCU_CHECK(de::inBounds(ndx, 0, getDataTypeMatrixNumColumns(curType.getBasicType())));				path.push_back(VarTypeComponent(VarTypeComponent::MATRIX_COLUMN, ndx));			}			else if (curType.isBasicType() && isDataTypeVector(curType.getBasicType()))			{				TCU_CHECK(de::inBounds(ndx, 0, getDataTypeScalarSize(curType.getBasicType())));				path.push_back(VarTypeComponent(VarTypeComponent::VECTOR_COMPONENT, ndx));			}			else				TCU_FAIL("Invalid subscript");			tokenizer.advance();			TCU_CHECK(tokenizer.getToken() == VarTokenizer::TOKEN_RIGHT_BRACKET);			tokenizer.advance();		}		else			TCU_FAIL("Unexpected token");	}}
开发者ID:MIPS,项目名称:external-deqp,代码行数:64,


示例10: Split

	vector<string> Split(const string& str, const string& separators) {		Poco::StringTokenizer tokenizer(str, separators);		vector<string> tokens(tokenizer.begin(), tokenizer.end());		return tokens;	}
开发者ID:panmar,项目名称:pg3,代码行数:5,


示例11: tokenizer

void ChatManagerImplementation::handleSocialInternalMessage(CreatureObject* sender, const UnicodeString& arguments) {	if (sender->isPlayerCreature()) {		ManagedReference<PlayerObject*> senderGhost = sender->getPlayerObject();		if (senderGhost == NULL)			return;		if (senderGhost->isMuted()) {			String reason = senderGhost->getMutedReason();			if (reason != "")				sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support for '" + reason + "'.");			else				sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support.");			return;		}	}	Zone* zone = sender->getZone();	if (zone == NULL)		return;	StringTokenizer tokenizer(arguments.toString());	uint64 targetid;	uint32 emoteid, unkint, unkint2;	try {		targetid = tokenizer.getLongToken();		emoteid = tokenizer.getIntToken();		unkint = tokenizer.getIntToken();		unkint2 = tokenizer.getIntToken();	} catch (const Exception& e) {		return;	}	//bool readlock = !zone->isLockedByCurrentThread();	bool showtext = true;	if (unkint2 == 0)		showtext = false;	String firstName;	if (sender->isPlayerCreature())		firstName = (cast<CreatureObject*>(sender))->getFirstName().toLowerCase();	CloseObjectsVector* vec = (CloseObjectsVector*) sender->getCloseObjects();	SortedVector<QuadTreeEntry* > closeEntryObjects(200, 50);	if (vec != NULL) {		vec->safeCopyTo(closeEntryObjects);	} else {		sender->info("Null closeobjects vector in ChatManager::handleSocialInternalMessage", true);		zone->getInRangeObjects(sender->getWorldPositionX(), sender->getWorldPositionX(), 128, &closeEntryObjects, true);	}	float range = defaultSpatialChatDistance;	for (int i = 0; i < closeEntryObjects.size(); ++i) {		SceneObject* object = cast<SceneObject*>(closeEntryObjects.get(i));		if (object->isPlayerCreature()) {			CreatureObject* creature = cast<CreatureObject*>(object);			Reference<PlayerObject*> ghost = creature->getSlottedObject("ghost").castTo<PlayerObject*>();			if (ghost == NULL)				continue;			if (!ghost->isIgnoring(firstName) && creature->isInRange(sender, range)) {				Emote* emsg = new Emote(creature, sender, targetid, emoteid, showtext);				creature->sendMessage(emsg);			}		}	}}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:82,


示例12: sort

nsresultXULSortServiceImpl::InitializeSortState(nsIContent* aRootElement,                                        nsIContent* aContainer,                                        const nsAString& aSortKey,                                        const nsAString& aSortHints,                                        nsSortState* aSortState){  // used as an optimization for the content builder  if (aContainer != aSortState->lastContainer.get()) {    aSortState->lastContainer = aContainer;    aSortState->lastWasFirst = false;    aSortState->lastWasLast = false;  }  // The attributes allowed are either:  //    sort="key1 key2 ..."  // or sortResource="key1" sortResource2="key2"  // The latter is for backwards compatibility, and is equivalent to concatenating  // both values in the sort attribute  nsAutoString sort(aSortKey);  aSortState->sortKeys.Clear();  if (sort.IsEmpty()) {    nsAutoString sortResource, sortResource2;    aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortResource, sortResource);    if (!sortResource.IsEmpty()) {      nsCOMPtr<nsIAtom> sortkeyatom = NS_Atomize(sortResource);      aSortState->sortKeys.AppendObject(sortkeyatom);      sort.Append(sortResource);      aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortResource2, sortResource2);      if (!sortResource2.IsEmpty()) {        nsCOMPtr<nsIAtom> sortkeyatom2 = NS_Atomize(sortResource2);        aSortState->sortKeys.AppendObject(sortkeyatom2);        sort.Append(' ');        sort.Append(sortResource2);      }    }  }  else {    nsWhitespaceTokenizer tokenizer(sort);    while (tokenizer.hasMoreTokens()) {      nsCOMPtr<nsIAtom> keyatom = NS_Atomize(tokenizer.nextToken());      NS_ENSURE_TRUE(keyatom, NS_ERROR_OUT_OF_MEMORY);      aSortState->sortKeys.AppendObject(keyatom);    }  }  aSortState->sort.Assign(sort);  aSortState->direction = nsSortState_natural;  bool noNaturalState = false;  nsWhitespaceTokenizer tokenizer(aSortHints);  while (tokenizer.hasMoreTokens()) {    const nsDependentSubstring& token(tokenizer.nextToken());    if (token.EqualsLiteral("comparecase"))      aSortState->sortHints |= nsIXULSortService::SORT_COMPARECASE;    else if (token.EqualsLiteral("integer"))      aSortState->sortHints |= nsIXULSortService::SORT_INTEGER;    else if (token.EqualsLiteral("descending"))      aSortState->direction = nsSortState_descending;    else if (token.EqualsLiteral("ascending"))      aSortState->direction = nsSortState_ascending;    else if (token.EqualsLiteral("twostate"))      noNaturalState = true;  }  // if the twostate flag was set, the natural order is skipped and only  // ascending and descending are allowed  if (aSortState->direction == nsSortState_natural && noNaturalState) {    aSortState->direction = nsSortState_ascending;  }  // set up sort order info  aSortState->invertSort = false;  nsAutoString existingsort;  aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, existingsort);  nsAutoString existingsortDirection;  aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection, existingsortDirection);  // if just switching direction, set the invertSort flag  if (sort.Equals(existingsort)) {    if (aSortState->direction == nsSortState_descending) {      if (existingsortDirection.EqualsLiteral("ascending"))        aSortState->invertSort = true;    }    else if (aSortState->direction == nsSortState_ascending &&             existingsortDirection.EqualsLiteral("descending")) {      aSortState->invertSort = true;    }  }  // sort items between separators independently  aSortState->inbetweenSeparatorSort =    aRootElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::sortSeparators,                              nsGkAtoms::_true, eCaseMatters);  // sort static content (non template generated nodes) after generated content  aSortState->sortStaticsLast = aRootElement->AttrValueIs(kNameSpaceID_None,                                  nsGkAtoms::sortStaticsLast,//.........这里部分代码省略.........
开发者ID:bgrins,项目名称:gecko-dev,代码行数:101,


示例13: tokenizer

Common::Error GagEngine::ScriptEvent(const Common::String &value){	Common::StringTokenizer tokenizer(value, Common::String(_OPTION_PREFIX));	Event event;	event.name = tokenizer.nextToken();	event.name.trim();	if(event.name.empty())		return Common::Error(Common::kUnknownError, "[Script Event] unnamed event");	if(tokenizer.empty())		return Common::Error(Common::kUnknownError, "[Script Event] no options");	do	{		Common::String option_line(tokenizer.nextToken());		option_line.trim();		Option option;		ParseOption(option, option_line);		if(option.name == "C")		{			;		}		else if(option.name == "COMM")		{			;		}		else if(option.name == "DEST")		{			;		}		else if(option.name == "IMAGE")		{			;		}		else if(option.name == "KEYUP")		{			;		}		else if(option.name == "R")		{			;		}		else if(option.name == "RECT")		{			;		}		else if(option.name == "SOUR")		{			;		}		else if(option.name == "TRANSPARENT")		{			;		}		else if(option.name == "ZONE")		{			;		}		// command for on event execution		else		{			if(option.name[0] != '*')			{				event.commands.push_back(option);				//DEBUG#ifdef DEBUG_SKIM_SCRIPT				G_STRING_SET.insert(option.name);#endif			}		}	}	while(!tokenizer.empty());	_events.push_back(event);	return Common::Error(Common::kNoError);}
开发者ID:superg,项目名称:scummvm,代码行数:80,


示例14: engine

    Engine* FclImporter::fromString(const std::string& fcl) const {        FL_unique_ptr<Engine> engine(new Engine);        std::map<std::string, std::string> tags;        tags["VAR_INPUT"] = "END_VAR";        tags["VAR_OUTPUT"] = "END_VAR";        tags["FUZZIFY"] = "END_FUZZIFY";        tags["DEFUZZIFY"] = "END_DEFUZZIFY";        tags["RULEBLOCK"] = "END_RULEBLOCK";        std::map<std::string, std::string>::const_iterator tagFinder;        std::string currentTag = "", closingTag = "";        std::ostringstream block;        std::istringstream fclReader(fcl);        std::string line;        int lineNumber = 0;        while (std::getline(fclReader, line)) {            ++lineNumber;            std::vector<std::string> comments;            comments = Op::split(line, "//");            if (comments.size() > 1) {                line = comments.front();            }            comments = Op::split(line, "#");            if (comments.size() > 1) {                line = comments.front();            }            line = Op::trim(line);            if (line.empty() or line.at(0) == '%' or line.at(0) == '#'                    or (line.substr(0, 2) == "//")) {                continue;            }            line = fl::Op::findReplace(line, ";", "");            std::istringstream tokenizer(line);            std::string firstToken;            tokenizer >> firstToken;            if (firstToken == "FUNCTION_BLOCK") {                if (tokenizer.rdbuf()->in_avail() > 0) {                    std::ostringstream name;                    std::string token;                    tokenizer >> token;                    name << token;                    while (tokenizer >> token) {                        name << " " << token;                    }                    engine->setName(name.str());                }                continue;            }            if (firstToken == "END_FUNCTION_BLOCK") {                break;            }            if (currentTag.empty()) {                tagFinder = tags.find(firstToken);                if (tagFinder == tags.end()) {                    std::ostringstream ex;                    ex << "[syntax error] unknown block definition <" << firstToken                            << "> " << " in line " << lineNumber << ": " << line;                    throw fl::Exception(ex.str(), FL_AT);                }                currentTag = tagFinder->first;                closingTag = tagFinder->second;                block.str("");                block.clear();                block << line << "/n";                continue;            }            if (not currentTag.empty()) {                if (firstToken == closingTag) {                    processBlock(currentTag, block.str(), engine.get());                    currentTag = "";                    closingTag = "";                } else if (tags.find(firstToken) != tags.end()) {                    //if opening new block without closing the previous one                    std::ostringstream ex;                    ex << "[syntax error] expected <" << closingTag << "> before <"                            << firstToken << "> in line: " << line;                    throw fl::Exception(ex.str(), FL_AT);                } else {                    block << line << "/n";                }                continue;            }        }
开发者ID:Audeliano,项目名称:ros-indigo-robotino,代码行数:88,


示例15: tokenizer

void MessageServer::processMessage( pair<int, string > mes ){	cout << mes.first << " " << mes.second << endl;	string command;	string text;	Poco::StringTokenizer tokenizer(mes.second, "~");	bool invalid = false;	int tokCnt = tokenizer.count();	if( tokCnt < 1 && tokCnt > 2){		invalid = true;	} else {		command = tokenizer[0];		if(tokCnt > 1 ) text = tokenizer[1];		if( command.length() == 0 ){			invalid = true;		}	}	if( invalid ){		sendToUser( mes.first, "~ERR_INVMSGFRMT");		return;	}	// VALID format	if( command.compare("SETNICK") == 0 ){		if( text.length() == 0 ){			sendToUser( mes.first, "~ERR_EMPTYNICK");			return;		}		users.insert( pair<int, string>(mes.first, text ) );		sendToUser( mes.first, "~SUCCESS");	} else if( command.compare("MSG") == 0 ){		if( text.length() == 0){			sendToUser( mes.first, "~ERR_EMPTYMSG");			return;		}		string nick;		stringstream allMessage;		bool found = false;		if( users.find(mes.first) != users.end() ){			nick = users[ mes.first ];			found = true;		}		if( found ){			string mes(nick);			mes += ": ";			mes += text;			sendToAll( mes );		} else {			sendToUser( mes.first, "~ERR_NOTREG");		}	} else if( command.compare("QUIT") == 0 ) {		map<int, string>::iterator qu = users.find(mes.first);		if( qu != users.end() ){			string name = (*qu).second;			users.erase( qu );			stringstream allMessage;			allMessage << "User " << name << " leaving chat" << endl;			sendToAll( allMessage.str() );		}	}}
开发者ID:RomaNZZZ,项目名称:Patterns13,代码行数:67,


示例16: GetSystemProperty

void TskCarveExtractScalpel::carveFile(const std::string &unallocImgPath, const std::string &outputFolderPath, const std::string &stdOutFilePath, const std::string &stdErrFilePath) const{    try    {        // Find out where Scalpel is installed.        std::string scalpelDirPath = GetSystemProperty("SCALPEL_DIR");        if (scalpelDirPath.empty())        {            throw TskException("TskCarveExtractScalpel::configure : Scalpel directory not set");        }        if (!Poco::File(scalpelDirPath).exists())        {            std::stringstream msg;            msg << "TskCarveExtractScalpel::configure : specified Scalpel directory '" << scalpelDirPath << "' does not exist";            throw TskException(msg.str());        }        // Get the path to the Scalpel executable.        std::stringstream pathBuilder;        pathBuilder << scalpelDirPath << Poco::Path::separator() << SCALPEL_EXE_FILE_NAME;        std::string scalpelExePath = pathBuilder.str();        if (!Poco::File(scalpelExePath).exists())        {            std::stringstream msg;            msg << "TskCarveExtractScalpel::configure : Scalpel executable '" << scalpelExePath << "' does not exist";            throw TskException(msg.str());        }        // Get the path to the Scalpel config file.        std::string scalpelConfigFilePath = GetSystemProperty("SCALPEL_CONFIG_FILE");        if (!Poco::File(scalpelConfigFilePath).exists())        {            std::stringstream msg;            msg << "TskCarveExtractScalpel::TskCarveExtractScalpel : Scalpel config file '" << scalpelConfigFilePath << "' does not exist";            throw TskException(msg.str());        }        // Set the Scalpel command line: specify the Scalpel config file.        Poco::Process::Args args;        args.push_back("-c");        args.push_back(scalpelConfigFilePath);        // Set the Scalpel command line: allow for nested headers and footers.        args.push_back("-e");                // Set the Scalpel command line: put any carved files directly into the output folder.        args.push_back("-o");        args.push_back(outputFolderPath);        args.push_back("-O");        // Set the Scalpel command line: specify the file to carve.        args.push_back(unallocImgPath);        // Launch Scalpel with console output redirects.        Poco::Pipe outPipe;        Poco::Pipe errPipe;        Poco::ProcessHandle handle = Poco::Process::launch(scalpelExePath, args, NULL, &outPipe, &errPipe);        // Capture the console output. Note that Scalpel may block at times as it waits for this loop to empty the stream buffers.        Poco::PipeInputStream stdOutInputStream(outPipe);        Poco::FileOutputStream stdOutOutputStream(stdOutFilePath);        Poco::PipeInputStream stdErrInputStream(errPipe);        Poco::FileOutputStream stdErrOutputStream(stdErrFilePath);        while (stdOutInputStream || stdErrInputStream)        {            if (stdOutInputStream)            {                Poco::StreamCopier::copyStream(stdOutInputStream, stdOutOutputStream);            }            if (stdErrInputStream)            {                Poco::StreamCopier::copyStream(stdErrInputStream, stdErrOutputStream);            }        }            // Scalpel should be finished since the console output streams are closed.        int exitCode = Poco::Process::wait(handle);        stdOutOutputStream.flush();        stdErrOutputStream.flush();        // On the first invocation of Scalpel, record its use in the image database.        static bool toolInfoRecorded = false;        if (!toolInfoRecorded)        {            std::ifstream stdOutStream(stdOutFilePath.c_str());            if (stdOutStream)            {                std::string versionString;                std::getline(stdOutStream, versionString);                Poco::StringTokenizer tokenizer(versionString, "/t ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);                 if (tokenizer[0] == "Scalpel" && tokenizer[1] == "version")                {                    TskServices::Instance().getImgDB().addToolInfo("Scalpel", tokenizer[2].c_str());                    toolInfoRecorded = true;                }                else                {//.........这里部分代码省略.........
开发者ID:Smoss,项目名称:sleuthkit,代码行数:101,


示例17: Init

bool wxNativeFontInfo::FromUserString(const wxString& s){    // reset to the default state    Init();    // ToUserString() will quote the facename if it contains spaces, commas    // or semicolons: we must be able to understand that quoted text is    // a single token:    wxString toparse(s);    // parse a more or less free form string    wxStringTokenizer tokenizer(toparse, wxT(";, "), wxTOKEN_STRTOK);    wxString face;    unsigned long size;    bool weightfound = false, pointsizefound = false;#if wxUSE_FONTMAP    bool encodingfound = false;#endif    bool insideQuotes = false;    while ( tokenizer.HasMoreTokens() )    {        wxString token = tokenizer.GetNextToken();        // normalize it        token.Trim(true).Trim(false).MakeLower();        if (insideQuotes)        {            if (token.StartsWith("'") ||                token.EndsWith("'"))            {                insideQuotes = false;                // add this last token to the facename:                face += " " + token;                // normalize facename:                face = face.Trim(true).Trim(false);                face.Replace("'", "");                continue;            }        }        else        {            if (token.StartsWith("'"))                insideQuotes = true;        }        // look for the known tokens        if ( insideQuotes )        {            // only the facename may be quoted:            face += " " + token;            continue;        }        if ( token == wxT("underlined") || token == _("underlined") )        {            SetUnderlined(true);        }        else if ( token == wxT("strikethrough") || token == _("strikethrough") )        {            SetStrikethrough(true);        }        else if ( token == wxT("light") || token == _("light") )        {            SetWeight(wxFONTWEIGHT_LIGHT);            weightfound = true;        }        else if ( token == wxT("bold") || token == _("bold") )        {            SetWeight(wxFONTWEIGHT_BOLD);            weightfound = true;        }        else if ( token == wxT("italic") || token == _("italic") )        {            SetStyle(wxFONTSTYLE_ITALIC);        }        else if ( token.ToULong(&size) )        {            SetPointSize(size);            pointsizefound = true;        }        else        {#if wxUSE_FONTMAP            // try to interpret this as an encoding            wxFontEncoding encoding = wxFontMapper::Get()->CharsetToEncoding(token, false);            if ( encoding != wxFONTENCODING_DEFAULT &&                 encoding != wxFONTENCODING_SYSTEM )    // returned when the recognition failed        {            SetEncoding(encoding);                encodingfound = true;        }            else        {#endif // wxUSE_FONTMAP                // assume it is the face name//.........这里部分代码省略.........
开发者ID:Annovae,项目名称:Dolphin-Core,代码行数:101,


示例18: ParseHotkeyConfig

/* Function ParseHotkeyConfig * the input format is: shortcut  "key"  "function" * lines starting by # are ignored (comments) * lines like [xxx] are tags (example: [common] or [libedit] which identify sections */void ParseHotkeyConfig( const wxString&           data,                        struct EDA_HOTKEY_CONFIG* aDescList ){    // Read the config    wxStringTokenizer tokenizer( data, L"/r/n", wxTOKEN_STRTOK );    EDA_HOTKEY**      CurrentHotkeyList = 0;    while( tokenizer.HasMoreTokens() )    {        wxString          line = tokenizer.GetNextToken();        wxStringTokenizer lineTokenizer( line );        wxString          line_type = lineTokenizer.GetNextToken();        if( line_type[0]  == '#' ) //comment            continue;        if( line_type[0]  == '[' ) // A tag is found. search infos in list        {            CurrentHotkeyList = 0;            EDA_HOTKEY_CONFIG* DList = aDescList;            for( ; DList->m_HK_InfoList; DList++ )            {                if( *DList->m_SectionTag == line_type )                {                    CurrentHotkeyList = DList->m_HK_InfoList;                    break;                }            }            continue;        }        if( line_type == wxT( "$Endlist" ) )            break;        if( line_type != wxT( "shortcut" ) )            continue;        if( CurrentHotkeyList == NULL )            continue;        // Get the key name        lineTokenizer.SetString( lineTokenizer.GetString(), L"/"/r/n/t ", wxTOKEN_STRTOK );        wxString keyname = lineTokenizer.GetNextToken();        wxString remainder = lineTokenizer.GetString();        // Get the command name        wxString fctname = remainder.AfterFirst( '/"' ).BeforeFirst( '/"' );        // search the hotkey in current hotkey list        for( EDA_HOTKEY** list = CurrentHotkeyList; *list != NULL; list++ )        {            EDA_HOTKEY* hk_decr = *list;            if( hk_decr->m_InfoMsg == fctname )            {                int code = KeyCodeFromKeyName( keyname );                if( code )                    hk_decr->m_KeyCode = code;                break;            }        }    }}
开发者ID:morio,项目名称:kicad-source-mirror,代码行数:74,


示例19: MOZ_ASSERT

//staticvoid VolumeManager::InitConfig(){  MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());  // This function uses /system/etc/volume.cfg to add additional volumes  // to the Volume Manager.  //  // This is useful on devices like the Nexus 4, which have no physical sd card  // or dedicated partition.  //  // The format of the volume.cfg file is as follows:  // create volume-name mount-point  // configure volume-name preference preference-value  // Blank lines and lines starting with the hash character "#" will be ignored.  ScopedCloseFile fp;  int n = 0;  char line[255];  const char *filename = "/system/etc/volume.cfg";  if (!(fp = fopen(filename, "r"))) {    LOG("Unable to open volume configuration file '%s' - ignoring", filename);    return;  }  while(fgets(line, sizeof(line), fp)) {    n++;    if (line[0] == '#')      continue;    nsCString commandline(line);    nsCWhitespaceTokenizer tokenizer(commandline);    if (!tokenizer.hasMoreTokens()) {      // Blank line - ignore      continue;    }    nsCString command(tokenizer.nextToken());    if (command.EqualsLiteral("create")) {      if (!tokenizer.hasMoreTokens()) {        ERR("No vol_name in %s line %d",  filename, n);        continue;      }      nsCString volName(tokenizer.nextToken());      if (!tokenizer.hasMoreTokens()) {        ERR("No mount point for volume '%s'. %s line %d",             volName.get(), filename, n);        continue;      }      nsCString mountPoint(tokenizer.nextToken());      RefPtr<Volume> vol = FindAddVolumeByName(volName);      vol->SetFakeVolume(mountPoint);      continue;    }    if (command.EqualsLiteral("configure")) {      if (!tokenizer.hasMoreTokens()) {        ERR("No vol_name in %s line %d", filename, n);        continue;      }      nsCString volName(tokenizer.nextToken());      if (!tokenizer.hasMoreTokens()) {        ERR("No configuration name specified for volume '%s'. %s line %d",             volName.get(), filename, n);        continue;      }      nsCString configName(tokenizer.nextToken());      if (!tokenizer.hasMoreTokens()) {        ERR("No value for configuration name '%s'. %s line %d",            configName.get(), filename, n);        continue;      }      nsCString configValue(tokenizer.nextToken());      RefPtr<Volume> vol = FindVolumeByName(volName);      if (vol) {        vol->SetConfig(configName, configValue);      } else {        ERR("Invalid volume name '%s'.", volName.get());      }      continue;    }    if (command.EqualsLiteral("ignore")) {      // This command is useful to remove volumes which are being tracked by      // vold, but for which we have no interest.      if (!tokenizer.hasMoreTokens()) {        ERR("No vol_name in %s line %d", filename, n);        continue;      }      nsCString volName(tokenizer.nextToken());      RemoveVolumeByName(volName);      continue;    }    ERR("Unrecognized command: '%s'", command.get());  }}
开发者ID:70599,项目名称:Waterfox,代码行数:94,


示例20: FL_DBG

    void Antecedent::load(const std::string& antecedent, fl::Rule* rule, const Engine* engine) {        FL_DBG("Antecedent: " << antecedent);        unload();        this->_text = antecedent;        if (fl::Op::trim(antecedent).empty()) {            throw fl::Exception("[syntax error] antecedent is empty", FL_AT);        }        /*         Builds an proposition tree from the antecedent of a fuzzy rule.         The rules are:         1) After a variable comes 'is',         2) After 'is' comes a hedge or a term         3) After a hedge comes a hedge or a term         4) After a term comes a variable or an operator         */        Function function;        std::string postfix = function.toPostfix(antecedent);        FL_DBG("Postfix: " << postfix);        std::stringstream tokenizer(postfix);        std::string token;        enum FSM {            S_VARIABLE = 1, S_IS = 2, S_HEDGE = 4, S_TERM = 8, S_AND_OR = 16        };        int state = S_VARIABLE;        std::stack<Expression*> expressionStack;        Proposition* proposition = fl::null;        try {            while (tokenizer >> token) {                if (state bitand S_VARIABLE) {                    Variable* variable = fl::null;                    if (engine->hasInputVariable(token)) variable = engine->getInputVariable(token);                    else if (engine->hasOutputVariable(token)) variable = engine->getOutputVariable(token);                    if (variable) {                        proposition = new Proposition;                        proposition->variable = variable;                        expressionStack.push(proposition);                        state = S_IS;                        FL_DBG("Token <" << token << "> is variable");                        continue;                    }                }                if (state bitand S_IS) {                    if (token == Rule::isKeyword()) {                        state = S_HEDGE bitor S_TERM;                        FL_DBG("Token <" << token << "> is keyword");                        continue;                    }                }                if (state bitand S_HEDGE) {                    Hedge* hedge = rule->getHedge(token);                    if (not hedge) {                        HedgeFactory* factory = FactoryManager::instance()->hedge();                        if (factory->hasConstructor(token)) {                            hedge = factory->constructObject(token);                            rule->addHedge(hedge);                        }                    }                    if (hedge) {                        proposition->hedges.push_back(hedge);                        if (dynamic_cast<Any*> (hedge)) {                            state = S_VARIABLE bitor S_AND_OR;                        } else {                            state = S_HEDGE bitor S_TERM;                        }                        FL_DBG("Token <" << token << "> is hedge");                        continue;                    }                }                if (state bitand S_TERM) {                    if (proposition->variable->hasTerm(token)) {                        proposition->term = proposition->variable->getTerm(token);                        state = S_VARIABLE bitor S_AND_OR;                        FL_DBG("Token <" << token << "> is term");                        continue;                    }                }                if (state bitand S_AND_OR) {                    if (token == Rule::andKeyword() or token == Rule::orKeyword()) {                        if (expressionStack.size() < 2) {                            std::ostringstream ex;                            ex << "[syntax error] logical operator <" << token << "> expects two operands,"                                    << "but found <" << expressionStack.size() << "> in antecedent";                            throw fl::Exception(ex.str(), FL_AT);                        }                        Operator* fuzzyOperator = new Operator;                        fuzzyOperator->name = token;                        fuzzyOperator->right = expressionStack.top();                        expressionStack.pop();                        fuzzyOperator->left = expressionStack.top();                        expressionStack.pop();                        expressionStack.push(fuzzyOperator);//.........这里部分代码省略.........
开发者ID:ecksun,项目名称:fuzzylite,代码行数:101,


示例21: MOZ_ASSERT

nsresultGetDirectoryListingTaskParent::IOWork(){  MOZ_ASSERT(XRE_IsParentProcess(),             "Only call from parent process!");  MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!");  if (mFileSystem->IsShutdown()) {    return NS_ERROR_FAILURE;  }  bool exists;  nsresult rv = mTargetPath->Exists(&exists);  if (NS_WARN_IF(NS_FAILED(rv))) {    return rv;  }  if (!exists) {    if (!mFileSystem->ShouldCreateDirectory()) {      return NS_ERROR_DOM_FILE_NOT_FOUND_ERR;    }    rv = mTargetPath->Create(nsIFile::DIRECTORY_TYPE, 0777);    if (NS_WARN_IF(NS_FAILED(rv))) {      return rv;    }  }  // Get isDirectory.  bool isDir;  rv = mTargetPath->IsDirectory(&isDir);  if (NS_WARN_IF(NS_FAILED(rv))) {    return rv;  }  if (!isDir) {    return NS_ERROR_DOM_FILESYSTEM_TYPE_MISMATCH_ERR;  }  nsCOMPtr<nsISimpleEnumerator> entries;  rv = mTargetPath->GetDirectoryEntries(getter_AddRefs(entries));  if (NS_WARN_IF(NS_FAILED(rv))) {    return rv;  }  bool filterOutSensitive = false;  {    HTMLSplitOnSpacesTokenizer tokenizer(mFilters, ';');    nsAutoString token;    while (tokenizer.hasMoreTokens()) {      token = tokenizer.nextToken();      if (token.EqualsLiteral("filter-out-sensitive")) {        filterOutSensitive = true;      } else {        MOZ_CRASH("Unrecognized filter");      }    }  }  for (;;) {    bool hasMore = false;    if (NS_WARN_IF(NS_FAILED(entries->HasMoreElements(&hasMore))) || !hasMore) {      break;    }    nsCOMPtr<nsISupports> supp;    if (NS_WARN_IF(NS_FAILED(entries->GetNext(getter_AddRefs(supp))))) {      break;    }    nsCOMPtr<nsIFile> currFile = do_QueryInterface(supp);    MOZ_ASSERT(currFile);    bool isSpecial, isFile;    if (NS_WARN_IF(NS_FAILED(currFile->IsSpecial(&isSpecial))) ||        isSpecial) {      continue;    }    if (NS_WARN_IF(NS_FAILED(currFile->IsFile(&isFile)) ||                   NS_FAILED(currFile->IsDirectory(&isDir))) ||        !(isFile || isDir)) {      continue;    }    if (filterOutSensitive) {      bool isHidden;      if (NS_WARN_IF(NS_FAILED(currFile->IsHidden(&isHidden))) || isHidden) {        continue;      }      nsAutoString leafName;      if (NS_WARN_IF(NS_FAILED(currFile->GetLeafName(leafName)))) {        continue;      }      if (leafName[0] == char16_t('.')) {        continue;      }    }    nsAutoString path;    if (NS_WARN_IF(NS_FAILED(currFile->GetPath(path)))) {      continue;//.........这里部分代码省略.........
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:101,


示例22: expandArgumentMacros

TskModule::Status TskExecutableModule::execute(TskFile * fileToAnalyze){    try    {        // Perform macro expansion on command line args.        std::string arguments = expandArgumentMacros(m_arguments, fileToAnalyze);        // Split the arguments into a vector of strings.        Poco::StringTokenizer tokenizer(arguments, " ");        std::vector<std::string> vectorArgs(tokenizer.begin(), tokenizer.end());        // Perform macro expansion on our output location        std::string outFilePath = expandArgumentMacros(m_output, fileToAnalyze);        // If an output file has been specified we need to ensure that anything        // written to stdout gets put in the file. This is accomplished by passing        // a pipe to Poco::Process::launch and reading its contents once the process        // has terminated.        if (!outFilePath.empty())        {            // Create directories that may be missing along the path.            std::string outFilePathNoQuote(TskUtilities::stripQuotes(outFilePath));            Poco::Path outPath(outFilePathNoQuote);            Poco::File outDir(outPath.parent());            outDir.createDirectories();            // Create the output file if it does not exist.            Poco::File outFile(outFilePathNoQuote);            if (!outFile.exists())            {                outFile.createFile();            }            // Create process redirecting its output to a Pipe.            Poco::Pipe outPipe;            Poco::ProcessHandle handle = Poco::Process::launch(m_modulePath, vectorArgs, NULL, &outPipe, NULL);                        // Copy output from Pipe to the output file.            Poco::PipeInputStream istr(outPipe);            Poco::FileOutputStream ostr(outFile.path(), std::ios::out|std::ios::app);            while (istr)            {                Poco::StreamCopier::copyStream(istr, ostr);            }            // The process should be finished. Check its exit code.            int exitCode = Poco::Process::wait(handle);            if (exitCode != 0)            {                // If a module fails we log a warning message and continue.                std::wstringstream msg;                msg << L"TskExecutableModule::execute - Module (" << m_modulePath.c_str()                    << L") failed with exit code: " << exitCode << std::endl;                LOGWARN(msg.str());            }        }        else        {            // No output file was specified.            Poco::ProcessHandle handle = Poco::Process::launch(m_modulePath, vectorArgs);            // Wait for the process to complete            int exitCode = Poco::Process::wait(handle);            if (exitCode != 0)            {                // If a module fails we log a warning message and continue.                std::wstringstream msg;                msg << L"TskExecutableModule::execute - Module (" << m_modulePath.c_str()                    << L") failed with exit code: " << exitCode << std::endl;                LOGWARN(msg.str());            }        }    }    catch (Poco::Exception& ex)    {        std::wstringstream errorMsg;        errorMsg << L"TskExecutableModule::execute - Error: " << ex.displayText().c_str() << std::endl;        LOGERROR(errorMsg.str());        throw TskException("Module execution failed.");    }    return TskModule::OK;}
开发者ID:rieger-albsig,项目名称:sleuthkit,代码行数:88,


示例23: path_get_cdpath

bool path_get_cdpath(const wcstring &dir, wcstring *out, const wchar_t *wd,                     const env_vars_snapshot_t &env_vars) {    int err = ENOENT;    if (dir.empty()) return false;    if (wd) {        size_t len = wcslen(wd);        assert(wd[len - 1] == L'/');    }    wcstring_list_t paths;    if (dir.at(0) == L'/') {        // Absolute path.        paths.push_back(dir);    } else if (string_prefixes_string(L"./", dir) || string_prefixes_string(L"../", dir) ||               dir == L"." || dir == L"..") {        // Path is relative to the working directory.        wcstring path;        if (wd) path.append(wd);        path.append(dir);        paths.push_back(path);    } else {        // Respect CDPATH.        env_var_t path = env_vars.get(L"CDPATH");        if (path.missing_or_empty()) path = L".";  // we'll change this to the wd if we have one        wcstring nxt_path;        wcstokenizer tokenizer(path, ARRAY_SEP_STR);        while (tokenizer.next(nxt_path)) {            if (nxt_path == L"." && wd != NULL) {                // nxt_path is just '.', and we have a working directory, so use the wd instead.                // TODO: if nxt_path starts with ./ we need to replace the . with the wd.                nxt_path = wd;            }            expand_tilde(nxt_path);            // debug( 2, L"woot %ls/n", expanded_path.c_str() );            if (nxt_path.empty()) continue;            wcstring whole_path = nxt_path;            append_path_component(whole_path, dir);            paths.push_back(whole_path);        }    }    bool success = false;    for (wcstring_list_t::const_iterator iter = paths.begin(); iter != paths.end(); ++iter) {        struct stat buf;        const wcstring &dir = *iter;        if (wstat(dir, &buf) == 0) {            if (S_ISDIR(buf.st_mode)) {                success = true;                if (out) out->assign(dir);                break;            } else {                err = ENOTDIR;            }        }    }    if (!success) errno = err;    return success;}
开发者ID:AlexShiLucky,项目名称:fish-shell,代码行数:64,


示例24: unload

    void Consequent::load(const std::string& consequent, const Engine* engine) {        unload();        setText(consequent);        if (Op::trim(consequent).empty()) {            throw Exception("[syntax error] consequent is empty", FL_AT);        }        /**         Extracts the list of propositions from the consequent         The rules are:         1) After a variable comes 'is' or '=',         2) After 'is' comes a hedge or a term         3) After a hedge comes a hedge or a term         4) After a term comes operators 'and' or 'with'         5) After operator 'and' comes a variable         6) After operator 'with' comes a float         */        enum FSM {            S_VARIABLE = 1, S_IS = 2, S_HEDGE = 4, S_TERM = 8,            S_AND = 16, S_WITH = 32        };        int state = S_VARIABLE;        Proposition* proposition = fl::null;        std::stringstream tokenizer(consequent);        std::string token;        try {            while (tokenizer >> token) {                if (state bitand S_VARIABLE) {                    if (engine->hasOutputVariable(token)) {                        proposition = new Proposition;                        proposition->variable = engine->getOutputVariable(token);                        conclusions().push_back(proposition);                        state = S_IS;                        continue;                    }                }                if (state bitand S_IS) {                    if (token == Rule::isKeyword()) {                        state = S_HEDGE bitor S_TERM;                        continue;                    }                }                if (state bitand S_HEDGE) {                    HedgeFactory* factory = FactoryManager::instance()->hedge();                    if (factory->hasConstructor(token)) {                        Hedge* hedge = factory->constructObject(token);                        proposition->hedges.push_back(hedge);                        state = S_HEDGE bitor S_TERM;                        continue;                    }                }                if (state bitand S_TERM) {                    if (proposition->variable->hasTerm(token)) {                        proposition->term = proposition->variable->getTerm(token);                        state = S_AND bitor S_WITH;                        continue;                    }                }                if (state bitand S_AND) {                    if (token == Rule::andKeyword()) {                        state = S_VARIABLE;                        continue;                    }                }                //if reached this point, there was an error:                if (state bitand S_VARIABLE) {                    std::ostringstream ex;                    ex << "[syntax error] consequent expected output variable, but found <" << token << ">";                    throw Exception(ex.str(), FL_AT);                }                if (state bitand S_IS) {                    std::ostringstream ex;                    ex << "[syntax error] consequent expected keyword <" << Rule::isKeyword() << ">, "                            "but found <" << token << ">";                    throw Exception(ex.str(), FL_AT);                }                if ((state bitand S_HEDGE) or (state bitand S_TERM)) {                    std::ostringstream ex;                    ex << "[syntax error] consequent expected hedge or term, but found <" << token << ">";                    throw Exception(ex.str(), FL_AT);                }                if ((state bitand S_AND) or (state bitand S_WITH)) {                    std::ostringstream ex;                    ex << "[syntax error] consequent expected operator <" << Rule::andKeyword() << "> "                            << "or keyword <" << Rule::withKeyword() << ">, "                            << "but found <" << token << ">";                    throw Exception(ex.str(), FL_AT);                }                std::ostringstream ex;//.........这里部分代码省略.........
开发者ID:NatalProductions,项目名称:fuzzylite,代码行数:101,


示例25: path_get_path_core

static bool path_get_path_core(const wcstring &cmd, wcstring *out_path,                               const env_var_t &bin_path_var) {    int err = ENOENT;    debug(3, L"path_get_path( '%ls' )", cmd.c_str());    // If the command has a slash, it must be a full path.    if (cmd.find(L'/') != wcstring::npos) {        if (waccess(cmd, X_OK) != 0) {            return false;        }        struct stat buff;        if (wstat(cmd, &buff)) {            return false;        }        if (S_ISREG(buff.st_mode)) {            if (out_path) out_path->assign(cmd);            return true;        }        errno = EACCES;        return false;    }    wcstring bin_path;    if (!bin_path_var.missing()) {        bin_path = bin_path_var;    } else {        if (contains(PREFIX L"/bin", L"/bin", L"/usr/bin")) {            bin_path = L"/bin" ARRAY_SEP_STR L"/usr/bin";        } else {            bin_path = L"/bin" ARRAY_SEP_STR L"/usr/bin" ARRAY_SEP_STR PREFIX L"/bin";        }    }    wcstring nxt_path;    wcstokenizer tokenizer(bin_path, ARRAY_SEP_STR);    while (tokenizer.next(nxt_path)) {        if (nxt_path.empty()) continue;        append_path_component(nxt_path, cmd);        if (waccess(nxt_path, X_OK) == 0) {            struct stat buff;            if (wstat(nxt_path, &buff) == -1) {                if (errno != EACCES) {                    wperror(L"stat");                }                continue;            }            if (S_ISREG(buff.st_mode)) {                if (out_path) out_path->swap(nxt_path);                return true;            }            err = EACCES;        } else {            switch (errno) {                case ENOENT:                case ENAMETOOLONG:                case EACCES:                case ENOTDIR: {                    break;                }                default: {                    debug(1, MISSING_COMMAND_ERR_MSG, nxt_path.c_str());                    wperror(L"access");                }            }        }    }    errno = err;    return false;}
开发者ID:AlexShiLucky,项目名称:fish-shell,代码行数:71,


示例26: tokenizer

nsresultSVGPointList::SetValueFromString(const nsAString& aValue){  // The spec says that the list is parsed and accepted up to the first error  // encountered, so we must call CopyFrom even if an error occurs. We still  // want to throw any error code from setAttribute if there's a problem  // though, so we must take care to return any error code.  nsresult rv = NS_OK;  SVGPointList temp;  nsCharSeparatedTokenizerTemplate<IsSVGWhitespace>    tokenizer(aValue, ',', nsCharSeparatedTokenizer::SEPARATOR_OPTIONAL);  nsAutoCString str1, str2;  // outside loop to minimize memory churn  while (tokenizer.hasMoreTokens()) {    CopyUTF16toUTF8(tokenizer.nextToken(), str1);    const char *token1 = str1.get();    if (*token1 == '/0') {      rv = NS_ERROR_DOM_SYNTAX_ERR;      break;    }    char *end;    float x = float(PR_strtod(token1, &end));    if (end == token1 || !NS_finite(x)) {      rv = NS_ERROR_DOM_SYNTAX_ERR;      break;    }    const char *token2;    if (*end == '-') {      // It's possible for the token to be 10-30 which has      // no separator but needs to be parsed as 10, -30      token2 = end;    } else {      if (!tokenizer.hasMoreTokens()) {        rv = NS_ERROR_DOM_SYNTAX_ERR;        break;      }      CopyUTF16toUTF8(tokenizer.nextToken(), str2);      token2 = str2.get();      if (*token2 == '/0') {        rv = NS_ERROR_DOM_SYNTAX_ERR;        break;      }    }    float y = float(PR_strtod(token2, &end));    if (*end != '/0' || !NS_finite(y)) {      rv = NS_ERROR_DOM_SYNTAX_ERR;      break;    }    temp.AppendItem(SVGPoint(x, y));  }  if (tokenizer.lastTokenEndedWithSeparator()) {    rv = NS_ERROR_DOM_SYNTAX_ERR; // trailing comma  }  nsresult rv2 = CopyFrom(temp);  if (NS_FAILED(rv2)) {    return rv2; // prioritize OOM error code over syntax errors  }  return rv;}
开发者ID:ChicoTeam,项目名称:mozilla-central,代码行数:65,


示例27: tokenizer

void RE2NFA::tokenize(const QString &input){    symbols.clear();#if 1    RegExpTokenizer tokenizer(input);    Symbol sym;    int tok = tokenizer.lex();    while (tok != -1) {        Symbol sym;        sym.token = static_cast<Token>(tok);        sym.lexem = input.mid(tokenizer.lexemStart, tokenizer.lexemLength);        if (sym.token == TOK_QUOTED_STRING) {            sym.lexem.chop(1);            sym.lexem.remove(0, 1);            sym.token = TOK_STRING;        }        if (sym.token == TOK_STRING || sym.token == TOK_SEQUENCE) {            for (int i = 0; i < sym.lexem.length(); ++i) {                if (sym.lexem.at(i) == '//') {                    if (i >= sym.lexem.length() - 1)                        break;                    QChar ch = sym.lexem.at(i + 1);                    if (ch == QLatin1Char('n')) {                        ch = '/n';                    } else if (ch == QLatin1Char('r')) {                        ch = '/r';                    } else if (ch == QLatin1Char('t')) {                        ch = '/t';                    } else if (ch == QLatin1Char('f')) {                        ch = '/f';                    }                    sym.lexem.replace(i, 2, ch);                }            }        }        /*        if (sym.token == TOK_SEQUENCE) {            Symbol s;            s.token = TOK_LBRACKET;            s.lexem = "[";            symbols.append(s);            for (int i = 1; i < sym.lexem.length() - 1; ++i) {                s.token = TOK_STRING;                s.lexem = sym.lexem.at(i);                symbols.append(s);            }            s.token = TOK_RBRACKET;            s.lexem = "]";            symbols.append(s);            tok = tokenizer.lex();            continue;        }        */        symbols.append(sym);        tok = tokenizer.lex();    }#else    int pos = 0;    bool insideSet = false;    while (pos < input.length()) {        QChar ch = input.at(pos);        Symbol sym;        sym.column = pos;        sym.token = TOK_INVALID;        sym.lexem = QString(ch);        switch (ch.toLatin1()) {            case '"': {                if (insideSet) {                    sym.token = TOK_STRING;                    sym.lexem = QString(ch);                    symbols += sym;                    ++pos;                    continue;                }                if (pos + 1 >= input.length())                    return;                int quoteEnd = skipQuote(input, pos + 1);                sym.token = TOK_STRING;                sym.lexem = input.mid(pos + 1, quoteEnd - pos - 2);                symbols += sym;                pos = quoteEnd;                continue;            }            case '{':                sym.token = (insideSet ? TOK_STRING : TOK_LBRACE);                break;            case '}':                sym.token = (insideSet ? TOK_STRING : TOK_RBRACE);                break;            case '[':                insideSet = true;                sym.token = TOK_LBRACKET;//.........这里部分代码省略.........
开发者ID:fluxer,项目名称:katie,代码行数:101,


示例28: ti

void wxToolTip::Add(WXHWND hWnd){    HWND hwnd = (HWND)hWnd;    wxToolInfo ti(hwnd, m_id, m_rect);    // another possibility would be to specify LPSTR_TEXTCALLBACK here as we    // store the tooltip text ourselves anyhow, and provide it in response to    // TTN_NEEDTEXT (sent via WM_NOTIFY), but then we would be limited to 79    // character tooltips as this is the size of the szText buffer in    // NMTTDISPINFO struct -- and setting the tooltip here we can have tooltips    // of any length    ti.hwnd = hwnd;    ti.lpszText = const_cast<wxChar *>(m_text.wx_str());    if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )    {        wxLogDebug(wxT("Failed to create the tooltip '%s'"), m_text.c_str());        return;    }#ifdef TTM_SETMAXTIPWIDTH    if ( wxApp::GetComCtl32Version() >= 470 )    {        // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the        // extent of its first line as max value        HFONT hfont = (HFONT)            SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0);        if ( !hfont )        {            hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);            if ( !hfont )            {                wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)"));            }        }        MemoryHDC hdc;        if ( !hdc )        {            wxLogLastError(wxT("CreateCompatibleDC(NULL)"));        }        if ( !SelectObject(hdc, hfont) )        {            wxLogLastError(wxT("SelectObject(hfont)"));        }        // find the width of the widest line        int maxWidth = 0;        wxStringTokenizer tokenizer(m_text, wxT("/n"));        while ( tokenizer.HasMoreTokens() )        {            const wxString token = tokenizer.GetNextToken();            SIZE sz;            if ( !::GetTextExtentPoint32(hdc, token.wx_str(),                                         token.length(), &sz) )            {                wxLogLastError(wxT("GetTextExtentPoint32"));            }            if ( sz.cx > maxWidth )                maxWidth = sz.cx;        }        // limit size to ms_maxWidth, if set        if ( ms_maxWidth == 0 )        {            // this is more or less arbitrary but seems to work well            static const int DEFAULT_MAX_WIDTH = 400;            ms_maxWidth = wxGetClientDisplayRect().width / 2;            if ( ms_maxWidth > DEFAULT_MAX_WIDTH )                ms_maxWidth = DEFAULT_MAX_WIDTH;        }        if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth )            maxWidth = ms_maxWidth;        // only set a new width if it is bigger than the current setting:        // otherwise adding a tooltip with shorter line(s) than a previous        // one would result in breaking the longer lines unnecessarily as        // all our tooltips share the same maximal width        if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(),                                           TTM_GETMAXTIPWIDTH, 0) )        {            SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,                               wxUIntToPtr(maxWidth));        }    }    else#endif // TTM_SETMAXTIPWIDTH    {        // replace the '/n's with spaces because otherwise they appear as        // unprintable characters in the tooltip string        m_text.Replace(wxT("/n"), wxT(" "));//.........这里部分代码省略.........
开发者ID:erwincoumans,项目名称:wxWidgets,代码行数:101,


示例29: main

int main(int argc, char** argv){  try {    if (getoptions(argc, argv) != 0)       return 1;        expgram::NGramCounts ngram(ngram_file, shards, debug);        std::string  line;    tokens_type  tokens;    const int order = ngram.index.order();        while (std::getline(std::cin, line)) {      tokenizer_type tokenizer(line);            // Here, we store in vector<string>.            tokens.clear();      tokens.insert(tokens.end(), tokenizer.begin(), tokenizer.end());                  //      // Alternatively, you can try: (Remark: sentence is simply vector<word_type>)      //       // sentence.clear();      // sentence.insert(sentence.end(), tokenizer.begin(), tokenizer.end());      //      // and iterate over sentence type, not tokens.      //            //      // The above example still automatically convert word_type into word_type::id_type on the fly.      // An alternative faster approach is: (Remark: we assume id_set is vector<word_type::id_type> )      //      // id_set.clear();      // for (tokenizer_type::iterator titer = tokenizer.begin(); titer != tokenizer.end(); ++ titer)      //   id_set.push_back(ngram.index.vocab()[*titer]);      //      // then, you can iterate over id_set, not tokens.      //            //       // Note that the word_type will automatically assign id which may not      // match with the word-id assigned by the indexed ngram language model.      // This means that even OOV by the ngram language model may be assigned word-id.      // If you want to avoid this, here is a solution:      //      // const word_type::id_type unk_id = ngram.index.vocab()[vocab_type::UNK]      //      // id_set.clear();      // for (tokenizer_type::iterator titer = tokenizer.begin(); titer != tokenizer.end(); ++ titer)      //   id_set.push_back(ngram.index.vocab().exists(*titer) ? ngram.index.vocab()[*titer] : unk_id);      //      // ngram access must use containser that supports forward-iterator concepts.      // If not sure, use vector!      std::copy(tokens.begin(), tokens.end(), std::ostream_iterator<std::string>(std::cout, " "));      std::cout << ngram(tokens.begin(), tokens.end()) << std::endl;    }  }  catch (std::exception& err) {    std::cerr << "error: " << err.what() << std::endl;    return 1;  }  return 0;}
开发者ID:tarowatanabe,项目名称:expgram,代码行数:68,



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


C++ tolower函数代码示例
C++ token函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。