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


C++ pattern函数代码示例

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


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

示例1: KillProcess

static TInt KillProcess(const TDesC& aProcessName)
	{
	TFullName name;
	//TheTest.Printf(_L("Find and kill \"%S\" process.\n"), &aProcessName);
	TBuf<64> pattern(aProcessName);
	TInt length = pattern.Length();
	pattern += _L("*");
	TFindProcess procFinder(pattern);

	while (procFinder.Next(name) == KErrNone)
		{
		if (name.Length() > length)
			{//If found name is a string containing aProcessName string.
			TChar c(name[length]);
			if (c.IsAlphaDigit() ||
				c == TChar('_') ||
				c == TChar('-'))
				{
				// If the found name is other valid application name
				// starting with aProcessName string.
				//TheTest.Printf(_L(":: Process name: \"%S\".\n"), &name);
				continue;
				}
			}
		RProcess proc;
		if (proc.Open(name) == KErrNone)
			{
			//RPorcess::Kill() is expected to be used here.
			//But it is impossible, because the test application will need "PowerMgmt" capability.
			//But if the test application has "PowerMgmt" capability, then it won't be possible to use the 
			//sqlite3_secure library, which has "ProtServ" capability only.
			}
		proc.Close();
		}
	return KErrNone;
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:36,代码来源:tsqlitesecure_perf.cpp

示例2: fdic

void PreLearnWords::InitZi(){
    char line[1024];
    QFile fdic("dic_utf8.txt");
    DBControler::OpenDB();
    DBControler::CreateZITable();
    int index=0;
    if ( fdic.open( QIODevice::ReadOnly | QIODevice::Text ) ){
        while( !fdic.atEnd() ){
            memset((char *)line,0,1024);
            fdic.readLine(line,1024);
            QString str = QString::fromUtf8(line);
            if( str.startsWith("*")){
                QString pattern("\\*(.*) ([abcdefghijklmnopqrstuvwxyzīíǐìāáǎàōóǒòūúǔùüǖǘǚǜēéěèńň,]*)笔划:(.*)部首:(.*)五笔输入法");
                QRegExp rx(pattern);

                int pos = str.indexOf(rx);
                if(pos < 0){
                }else{
                    QStringList pinyin = rx.cap(2).split(",");
                    if( pinyin.size() == 0 || pinyin.at(0).length() == 0){
                        //qDebug() << rx.cap(1) << rx.cap(2) << rx.cap(3) << rx.cap(4);
                        DBControler::AddZItoTable(index++,rx.cap(1),rx.cap(2),rx.cap(3),rx.cap(4));
                    }else{
                        for( int i = 0 ; i < pinyin.size() ; i++){
                            if( pinyin.at(i).length() == 0) break;
                            else
                                DBControler::AddZItoTable(index++,rx.cap(1),pinyin.at(i),rx.cap(3),rx.cap(4));
                        }
                    }
                }
            }
        }

        fdic.close();
    }
}
开发者ID:flamenca,项目名称:Brain,代码行数:36,代码来源:prelearnwords.cpp

示例3: NativeDecimalFormat_open

static jlong NativeDecimalFormat_open(JNIEnv* env, jclass, jstring pattern0,
        jstring currencySymbol, jchar decimalSeparator, jchar digit, jstring exponentSeparator,
        jchar groupingSeparator, jstring infinity,
        jstring internationalCurrencySymbol, jstring minusSign,
        jchar monetaryDecimalSeparator, jstring nan, jchar patternSeparator,
        jstring percent, jchar perMill, jchar zeroDigit) {
    UErrorCode status = U_ZERO_ERROR;
    UParseError parseError;
    ScopedJavaUnicodeString pattern(env, pattern0);
    if (!pattern.valid()) {
      return 0;
    }
    DecimalFormatSymbols* symbols = makeDecimalFormatSymbols(env,
            currencySymbol, decimalSeparator, digit, exponentSeparator, groupingSeparator,
            infinity, internationalCurrencySymbol, minusSign,
            monetaryDecimalSeparator, nan, patternSeparator, percent, perMill,
            zeroDigit);
    DecimalFormat* fmt = new DecimalFormat(pattern.unicodeString(), symbols, parseError, status);
    if (fmt == NULL) {
        delete symbols;
    }
    maybeThrowIcuException(env, "DecimalFormat::DecimalFormat", status);
    return reinterpret_cast<uintptr_t>(fmt);
}
开发者ID:LeMaker,项目名称:android-actions,代码行数:24,代码来源:libcore_icu_NativeDecimalFormat.cpp

示例4: CleanUpThumbnailCache

// removes thumbnails that don't belong to any frequently used item in file history
void CleanUpThumbnailCache(const FileHistory& fileHistory) {
    AutoFreeW thumbsPath(AppGenDataFilename(THUMBNAILS_DIR_NAME));
    if (!thumbsPath)
        return;
    AutoFreeW pattern(path::Join(thumbsPath, L"*.png"));

    WStrVec files;
    WIN32_FIND_DATA fdata;

    HANDLE hfind = FindFirstFile(pattern, &fdata);
    if (INVALID_HANDLE_VALUE == hfind)
        return;
    do {
        if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
            files.Append(str::Dup(fdata.cFileName));
    } while (FindNextFile(hfind, &fdata));
    FindClose(hfind);

    Vec<DisplayState*> list;
    fileHistory.GetFrequencyOrder(list);
    for (size_t i = 0; i < list.size() && i < FILE_HISTORY_MAX_FREQUENT * 2; i++) {
        AutoFreeW bmpPath(GetThumbnailPath(list.at(i)->filePath));
        if (!bmpPath)
            continue;
        int idx = files.Find(path::GetBaseName(bmpPath));
        if (idx != -1) {
            CrashIf(idx < 0 || files.size() <= (size_t)idx);
            free(files.PopAt(idx));
        }
    }

    for (size_t i = 0; i < files.size(); i++) {
        AutoFreeW bmpPath(path::Join(thumbsPath, files.at(i)));
        file::Delete(bmpPath);
    }
}
开发者ID:jingyu9575,项目名称:sumatrapdf,代码行数:37,代码来源:FileThumbnails.cpp

示例5: pattern

FieldEditor* SymChooserImpl::add_filter(
    Style* s,
    const char* pattern_attribute, const char* default_pattern,
    const char* caption_attribute, const char* default_caption,
    Glyph* body, FieldEditorAction* action
) {
    String pattern(default_pattern);
    s->find_attribute(pattern_attribute, pattern);
    String caption(default_caption);
    s->find_attribute(caption_attribute, caption);
    FieldEditor* e = DialogKit::instance()->field_editor(pattern, s, action);
    fchooser_->append_input_handler(e);
    WidgetKit& kit = *kit_;
    LayoutKit& layout = *LayoutKit::instance();
    body->append(
	layout.hbox(
	    layout.vcenter(kit.fancy_label(caption), 0.5),
	    layout.hspace(2.0),
	    layout.vcenter(e, 0.5)
	)
    );
    body->append(layout.vspace(10.0));
    return e;
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:24,代码来源:symchoos.cpp

示例6: bservInitMaps

void bservInitMaps()
{
	WIN32_FIND_DATA fData;
    wstring pattern(getPesInfo()->gdbDir);
    pattern += L"GDB\\balls\\*";

	HANDLE hff = FindFirstFile(pattern.c_str(), &fData);
    if (hff != INVALID_HANDLE_VALUE)
    {
        while(true)
        {
            // check if this is a file
            if ((fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0
                    && wcsicmp(fData.cFileName,L"map.txt")!=0)
            {
                ball_t ball;
                ball._file = fData.cFileName;

                if (ball._file.size() > 0x2f)
                {
                    LOG1S1N(L"ERROR: Ball filename too long for {%s}: %d characters. Must be 0-47. Skipping.", ball._file.c_str(), ball._file.size());
                }
                else
                {
                    _balls.insert(pair<wstring,ball_t>(
                                fData.cFileName, ball
                    ));
                }
            }

            // proceed to next file
            if (!FindNextFile(hff, &fData)) break;
        }
        FindClose(hff);
    }

    // read home-ball map
    hash_map<WORD,wstring> entries;
    wstring mapFile(getPesInfo()->gdbDir);
    mapFile += L"GDB\\balls\\map.txt";
    if (readMap(mapFile.c_str(), entries))
    {
        for (hash_map<WORD,wstring>::iterator it = entries.begin();
                it != entries.end();
                it++)
        {
            wstring dir(it->second);
            string_strip(dir);
            string_strip_quotes(dir);

            // find this ball in the normal map
            ball_iter_t sit = _balls.find(dir);
            if (sit != _balls.end())
                _home_balls.insert(pair<WORD,ball_iter_t>(
                            it->first, sit));
            else
                LOG1S(L"ERROR in home-balls map: ball {%s} not found. Skipping.", dir.c_str());
        }
    }

    LOG1N(L"total balls: %d", _balls.size());
    LOG1N(L"home balls assigned: %d", _home_balls.size());

    // reset the iterator
    _ball_iter = _balls.end();
}
开发者ID:kitserver,项目名称:kitserver8,代码行数:66,代码来源:bserv.cpp

示例7: pattern

void CanvasPattern::setTransform(SVGMatrixTearOff* transform)
{
    pattern()->setPatternSpaceTransform(transform ? transform->value() : AffineTransform(1, 0, 0, 1, 0, 0));
}
开发者ID:alexanderbill,项目名称:blink-crosswalk,代码行数:4,代码来源:CanvasPattern.cpp

示例8: pattern

Component& Component::version(const std::string& version,const std::string& message) {
	std::string new_version;
	std::string tag_message = message;
	std::string current_version = Component::version();

	boost::regex pattern("^(\\d+)\\.(\\d+)\\.(\\d+)$");

	auto regex_uint = [](const boost::smatch& matches,unsigned int index){
		return boost::lexical_cast<unsigned int>(std::string(matches[index].first,matches[index].second));
	};

	// Extract the semantic parts of the current version
	unsigned int current_major = 0;
	unsigned int current_minor = 0;
	unsigned int current_patch = 0;
	boost::smatch matches;
	if(boost::regex_match(current_version,matches,pattern)){
		current_major = regex_uint(matches,1);
		current_minor = regex_uint(matches,2);
		current_patch = regex_uint(matches,3);
	}

	if(version=="patch"){
		// Increment the patch number
		new_version = str(boost::format("%d.%d.%d")%current_major%current_minor%(current_patch+1));
	}
	else if(version=="minor"){
		// Increment the minor version number
		new_version = str(boost::format("%d.%d.0")%current_major%(current_minor+1));
	}
	else if(version=="major"){
		// Increment the minor version number
		new_version = str(boost::format("%d.0.0")%(current_major+1));
	}
	else {
		// Check that the supplied version is greater, or equal to the current
		// version
		unsigned int new_major,new_minor,new_patch;
		boost::smatch matches;
		if(boost::regex_match(version,matches,pattern)){
			new_major = regex_uint(matches,1);
			if(new_major<current_major) throw Exception(str(
				boost::format("Major version supplied is less than current major version (%d): %d")%current_major%new_major
			));
			new_minor = regex_uint(matches,2);
			if(new_major==current_major and new_minor<current_minor) throw Exception(str(
				boost::format("Minor version supplied is less than current minor version (%d): %d")%current_minor%new_minor
			));
			new_patch = regex_uint(matches,3);
			if(new_major==current_major and new_minor==current_minor and new_patch<current_patch) throw Exception(str(
				boost::format("Path version supplied is less than current path version (%d): %d")%current_patch%new_patch
			));
		} else {
			STENCILA_THROW(Exception,"Version supplied is not in correct format (e.g. 1.3.2): "+version);
		}
		new_version = version;
	}

	if(tag_message.length()==0) tag_message = "Versioned changed to " + new_version;
	std::string name = "";
	std::string email = "";
	// Get, or create, repository for the component and tag it.
	Repository* repo = this->repo(true);
	if(repo->head()=="<none>") STENCILA_THROW(Exception,"Component has not been commited. Please do a commit() before a version().");
	repo->tag(new_version,tag_message,name,email);
	return *this;
}
开发者ID:michael,项目名称:stencila,代码行数:67,代码来源:component-repo.cpp

示例9: ASSERT

void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
                        const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
{
    if (!nativeImageForCurrentFrame())
        return;

    ASSERT(patternTransform.isInvertible());
    if (!patternTransform.isInvertible())
        // Avoid a hang under CGContextDrawTiledImage on release builds.
        return;

    CGContextRef context = ctxt->platformContext();
    ctxt->save();
    CGContextClipToRect(context, destRect);
    ctxt->setCompositeOperation(op);
    CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height());
    CGContextScaleCTM(context, 1, -1);
    
    // Compute the scaled tile size.
    float scaledTileHeight = tileRect.height() * narrowPrecisionToFloat(patternTransform.d());
    
    // We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being
    // the origin).
    float adjustedX = phase.x() - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out.
    float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight);

    CGImageRef tileImage = nativeImageForCurrentFrame();
    float h = CGImageGetHeight(tileImage);

    RetainPtr<CGImageRef> subImage;
    if (tileRect.size() == size())
        subImage = tileImage;
    else {
        // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
        // because sub-images are only used for border-image, which only renders when the image is fully decoded.
        ASSERT(h == height());
        subImage.adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect));
    }

    // Adjust the color space.
    subImage = imageWithColorSpace(subImage.get(), styleColorSpace);
    
#ifndef BUILDING_ON_TIGER
    // Leopard has an optimized call for the tiling of image patterns, but we can only use it if the image has been decoded enough that
    // its buffer is the same size as the overall image.  Because a partially decoded CGImageRef with a smaller width or height than the
    // overall image buffer needs to tile with "gaps", we can't use the optimized tiling call in that case.
    // FIXME: Could create WebKitSystemInterface SPI for CGCreatePatternWithImage2 and probably make Tiger tile faster as well.
    // FIXME: We cannot use CGContextDrawTiledImage with scaled tiles on Leopard, because it suffers from rounding errors.  Snow Leopard is ok.
    float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
    float w = CGImageGetWidth(tileImage);
#ifdef BUILDING_ON_LEOPARD
    if (w == size().width() && h == size().height() && scaledTileWidth == tileRect.width() && scaledTileHeight == tileRect.height())
#else
    if (w == size().width() && h == size().height())
#endif
        CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get());
    else {
#endif

    // On Leopard, this code now only runs for partially decoded images whose buffers do not yet match the overall size of the image.
    // On Tiger this code runs all the time.  This code is suboptimal because the pattern does not reference the image directly, and the
    // pattern is destroyed before exiting the function.  This means any decoding the pattern does doesn't end up cached anywhere, so we
    // redecode every time we paint.
    static const CGPatternCallbacks patternCallbacks = { 0, drawPatternCallback, NULL };
    CGAffineTransform matrix = CGAffineTransformMake(narrowPrecisionToCGFloat(patternTransform.a()), 0, 0, narrowPrecisionToCGFloat(patternTransform.d()), adjustedX, adjustedY);
    matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context));
    // The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top.
    matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h);
    RetainPtr<CGPatternRef> pattern(AdoptCF, CGPatternCreate(subImage.get(), CGRectMake(0, 0, tileRect.width(), tileRect.height()),
                                             matrix, tileRect.width(), tileRect.height(), 
                                             kCGPatternTilingConstantSpacing, true, &patternCallbacks));
    if (!pattern) {
        ctxt->restore();
        return;
    }

    RetainPtr<CGColorSpaceRef> patternSpace(AdoptCF, CGColorSpaceCreatePattern(0));
    
    CGFloat alpha = 1;
    RetainPtr<CGColorRef> color(AdoptCF, CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &alpha));
    CGContextSetFillColorSpace(context, patternSpace.get());

    // FIXME: Really want a public API for this.  It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
    wkSetPatternBaseCTM(context, CGAffineTransformIdentity);
    CGContextSetPatternPhase(context, CGSizeZero);

    CGContextSetFillColorWithColor(context, color.get());
    CGContextFillRect(context, CGContextGetClipBoundingBox(context));

#ifndef BUILDING_ON_TIGER
    }
#endif

    ctxt->restore();

    if (imageObserver())
        imageObserver()->didDraw(this);
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:98,代码来源:ImageCG.cpp

示例10: u_strFromUTF8

void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesLen,
               UErrorCode &status) {

    // Convert the user input data from UTF-8 to UChar (UTF-16)
    int32_t inputLen = 0;
    if (U_FAILURE(status)) {
        return;
    }
    u_strFromUTF8(NULL, 0, &inputLen, confusables, confusablesLen, &status);
    if (status != U_BUFFER_OVERFLOW_ERROR) {
        return;
    }
    status = U_ZERO_ERROR;
    fInput = static_cast<UChar *>(uprv_malloc((inputLen+1) * sizeof(UChar)));
    if (fInput == NULL) {
        status = U_MEMORY_ALLOCATION_ERROR;
        return;
    }
    u_strFromUTF8(fInput, inputLen+1, NULL, confusables, confusablesLen, &status);


    // Regular Expression to parse a line from Confusables.txt.  The expression will match
    // any line.  What was matched is determined by examining which capture groups have a match.
    //   Capture Group 1:  the source char
    //   Capture Group 2:  the replacement chars
    //   Capture Group 3-6  the table type, SL, SA, ML, or MA
    //   Capture Group 7:  A blank or comment only line.
    //   Capture Group 8:  A syntactically invalid line.  Anything that didn't match before.
    // Example Line from the confusables.txt source file:
    //   "1D702 ;	006E 0329 ;	SL	# MATHEMATICAL ITALIC SMALL ETA ... "
    UnicodeString pattern(
        "(?m)^[ \\t]*([0-9A-Fa-f]+)[ \\t]+;"      // Match the source char
        "[ \\t]*([0-9A-Fa-f]+"                    // Match the replacement char(s)
           "(?:[ \\t]+[0-9A-Fa-f]+)*)[ \\t]*;"    //     (continued)
        "\\s*(?:(SL)|(SA)|(ML)|(MA))"             // Match the table type
        "[ \\t]*(?:#.*?)?$"                       // Match any trailing #comment
        "|^([ \\t]*(?:#.*?)?)$"       // OR match empty lines or lines with only a #comment
        "|^(.*?)$", -1, US_INV);      // OR match any line, which catches illegal lines.
    // TODO: Why are we using the regex C API here? C++ would just take UnicodeString...
    fParseLine = uregex_open(pattern.getBuffer(), pattern.length(), 0, NULL, &status);

    // Regular expression for parsing a hex number out of a space-separated list of them.
    //   Capture group 1 gets the number, with spaces removed.
    pattern = UNICODE_STRING_SIMPLE("\\s*([0-9A-F]+)");
    fParseHexNum = uregex_open(pattern.getBuffer(), pattern.length(), 0, NULL, &status);

    // Zap any Byte Order Mark at the start of input.  Changing it to a space is benign
    //   given the syntax of the input.
    if (*fInput == 0xfeff) {
        *fInput = 0x20;
    }

    // Parse the input, one line per iteration of this loop.
    uregex_setText(fParseLine, fInput, inputLen, &status);
    while (uregex_findNext(fParseLine, &status)) {
        fLineNum++;
        if (uregex_start(fParseLine, 7, &status) >= 0) {
            // this was a blank or comment line.
            continue;
        }
        if (uregex_start(fParseLine, 8, &status) >= 0) {
            // input file syntax error.
            status = U_PARSE_ERROR;
            return;
        }

        // We have a good input line.  Extract the key character and mapping string, and
        //    put them into the appropriate mapping table.
        UChar32 keyChar = SpoofImpl::ScanHex(fInput, uregex_start(fParseLine, 1, &status),
                          uregex_end(fParseLine, 1, &status), status);

        int32_t mapStringStart = uregex_start(fParseLine, 2, &status);
        int32_t mapStringLength = uregex_end(fParseLine, 2, &status) - mapStringStart;
        uregex_setText(fParseHexNum, &fInput[mapStringStart], mapStringLength, &status);

        UnicodeString  *mapString = new UnicodeString();
        if (mapString == NULL) {
            status = U_MEMORY_ALLOCATION_ERROR;
            return;
        }
        while (uregex_findNext(fParseHexNum, &status)) {
            UChar32 c = SpoofImpl::ScanHex(&fInput[mapStringStart], uregex_start(fParseHexNum, 1, &status),
                                 uregex_end(fParseHexNum, 1, &status), status);
            mapString->append(c);
        }
        U_ASSERT(mapString->length() >= 1);

        // Put the map (value) string into the string pool
        // This a little like a Java intern() - any duplicates will be eliminated.
        SPUString *smapString = stringPool->addString(mapString, status);

        // Add the UChar32 -> string mapping to the appropriate table.
        UHashtable *table = uregex_start(fParseLine, 3, &status) >= 0 ? fSLTable :
                            uregex_start(fParseLine, 4, &status) >= 0 ? fSATable :
                            uregex_start(fParseLine, 5, &status) >= 0 ? fMLTable :
                            uregex_start(fParseLine, 6, &status) >= 0 ? fMATable :
                            NULL;
        if (U_SUCCESS(status) && table == NULL) {
            status = U_PARSE_ERROR;
        }
//.........这里部分代码省略.........
开发者ID:119120119,项目名称:node,代码行数:101,代码来源:uspoof_conf.cpp

示例11: pattern

bool
InverseAngstromsUnitFactory::canInterpret(const std::string &unitString) const {
    boost::regex pattern("(Angstrom\\^-1)");
    boost::smatch match; // Unused.
    return boost::regex_search(unitString, match, pattern);
}
开发者ID:stothe2,项目名称:mantid,代码行数:6,代码来源:MDUnitFactory.cpp

示例12: small_blocks

void small_blocks(::std::vector<table_entry*> & links, map<unsigned long long, string> &chains, unsigned int len,
                  map<unsigned long long, unsigned long long>& mapping){
    map<unsigned long long, string>::iterator ch_iter;
    ::std::vector<small_frag> short_blocks;
    stack<unsigned int> s;
    for(unsigned int i=0; i<links.size(); ++i){
        for(unsigned int j=0; j<links.size(); ++j){
            if(i!=j && links[i]->size_D_link() != 0 && links[i]->size_A_link() == 0
               && links[j]->size_D_link() == 0 && links[j]->size_A_link() != 0 ){
                
                string s1,s2;
                ::seqan::assign(s1,links[i]->get_short_read()->get_RNA_seq_sequence());
                ::seqan::assign(s2,links[j]->get_short_read()->get_RNA_seq_sequence());
                
		//Overlap between s1 and s2 grater or equal than s1/2
                unsigned int overlap = overlappedStringLength(s1,s2);
                
                if(overlap > 0 && overlap <= s1.length()/2){
                    assign(s2,::seqan::suffix(s2,overlap));
                    s1.append(s2);
                    //::std::cout << s1 << " " << s1.length() << ::std::endl;
                    small_frag f;
                    f.frag_links.D_chain = i;
                    f.frag_links.A_chain = j;
                    f.frag = ::seqan::infix(s1,len, s1.length() - len);
                    //::std::cout << overlap << " " << f.frag << " " << length(f.frag) << ::std::endl;
                    short_blocks.push_back(f);
                }
            }
        }
    }
    for(unsigned int i=0; i<short_blocks.size(); ++i){
        bool sub_seq = false;
        for(unsigned int k=0; k<short_blocks.size(); ++k){
            if(short_blocks[i].frag == short_blocks[k].frag && i>k){
                links_pair erased_links;
                erased_links.D_chain = short_blocks[i].frag_links.D_chain;
                erased_links.A_chain = short_blocks[i].frag_links.A_chain;
                short_blocks[k].other_links.push_back(erased_links);
                sub_seq = true;
            }
            if(i!=k && (::seqan::length(short_blocks[i].frag)) > (::seqan::length(short_blocks[k].frag))){
                Finder<CharString> finder(short_blocks[i].frag);
                Pattern<CharString, ShiftAnd> pattern(short_blocks[k].frag);
                if(find(finder,pattern)){
                    links_pair erased_links;
                    erased_links.D_chain = short_blocks[i].frag_links.D_chain;
                    erased_links.A_chain = short_blocks[i].frag_links.A_chain;
                    //::std::cout << i << k << " - " << beginPosition(finder) << " " << endPosition(finder) << ::std::endl;
                    short_blocks[k].other_links.push_back(erased_links);
                    sub_seq = true;
                }
            }
        }
        if(sub_seq){
            s.push(i);
        }
    }
    
    while(!s.empty()){
        short_blocks.erase(short_blocks.begin()+s.top());
        s.pop();
    }

    for(unsigned int i=0; i<short_blocks.size(); ++i){
        //::std::cout << short_blocks[i].frag << " " << length(short_blocks[i].frag) << ::std::endl;
        string ch;
        assign(ch,::seqan::prefix(short_blocks[i].frag,len));
        //::std::cout << ch << " " << ch.length() << ::std::endl;
        if(chains.find(fingerprint(ch)) == chains.end()){
            chains[fingerprint(ch)] = ::seqan::toCString(short_blocks[i].frag);
            //::std::cout << ::seqan::toCString(short_blocks[i].frag) << " " << length(short_blocks[i].frag) << ::std::endl;
            mapping[fingerprint(ch)] = fingerprint(ch);
            links[short_blocks[i].frag_links.D_chain]->push_A_link(fingerprint(ch));
            links[short_blocks[i].frag_links.A_chain]->push_D_link(fingerprint(ch));
        }
        for(unsigned int j=0; j<short_blocks[i].other_links.size(); ++j){
            links[short_blocks[i].other_links[j].D_chain]->push_A_link(fingerprint(ch));
            links[short_blocks[i].other_links[j].A_chain]->push_D_link(fingerprint(ch));
        }
    }
}
开发者ID:hjanime,项目名称:RNA-seq-Graph,代码行数:82,代码来源:graph_refinement.cpp

示例13: check_overlapping_nodes

void check_overlapping_nodes(::std::vector<table_entry*> & links, map<unsigned long long, string> & chains, int len,
                             ::std::map<unsigned long long, unsigned long long>& mapping, unsigned int min_overlap,
                             int ov_perc){
    ::std::map<unsigned long long, string>::iterator chain_it;
    ::std::map<unsigned long long, string>::iterator chain_it_2;
    ::std::vector<small_frag> short_blocks;
    stack<unsigned int> s;
    queue<unsigned long long> q;
    for(chain_it = chains.begin(); chain_it != chains.end(); ++chain_it){
        for(chain_it_2 = chains.begin(); chain_it_2 != chains.end(); ++chain_it_2){
            unsigned int ov = overlappedStringLength(chain_it->second,chain_it_2->second);
            if(chain_it != chain_it_2 && ov < (ov_perc*chain_it->second.length())/100 &&
               (ov_perc*ov < chain_it_2->second.length())/100 && ov > min_overlap){
                bool new_node = false;
                CharString pat_text=prefix(chain_it_2->second,ov);
                //::std::cout << chain_it->second << ::std::endl;
                //::std::cout << chain_it_2->second << ::std::endl;
                //::std::cout << ov << ::std::endl;
                Pattern<CharString, ShiftAnd> pattern(pat_text);
                for(unsigned int i=0; i<links.size();++i){
                    CharString link_read = links[i]->get_short_read()->get_RNA_seq_sequence();
                    Finder<CharString> finder(link_read);
                    if(find(finder,pattern) && (
                       prefix(link_read,beginPosition(finder)) == infix(chain_it->second,chain_it->second.length()-ov-beginPosition(finder),chain_it->second.length()-ov) ||
                       suffix(link_read,length(link_read) - endPosition(finder)) == infix(chain_it_2->second,ov,ov+endPosition(finder)))){
                        //::std::cout << link_read << ::std::endl;
                        //::std::cout << prefix(link_read,beginPosition(finder)) << ::std::endl;
                        //::std::cout << infix(chain_it->second,chain_it->second.length()-ov-beginPosition(finder),chain_it->second.length()-ov) << ::std::endl;
                        //::std::cout << suffix(link_read,length(link_read) - endPosition(finder)) << ::std::endl;
                        //::std::cout << infix(chain_it_2->second,ov,ov+endPosition(finder)) << ::std::endl;
                      
                        new_node = true;
                    }
                }
                if(new_node){
                    small_frag f;
                    f.frag_links.D_chain = chain_it->first;
                    f.frag_links.A_chain = chain_it_2->first;
                    f.frag = prefix(chain_it_2->second,ov);
                    short_blocks.push_back(f);
                }
            }else{
                if(chain_it != chain_it_2 && ov>=(ov_perc*chain_it->second.length())/100){
                    //::std::cout << "Chain_it sub-node of Chain_it_2" << ::std::endl;
                    //::std::cout << "Chain_it " << chain_it->second << ::std::endl;
                    //::std::cout << "Chain_it_2 " << chain_it_2->second << ::std::endl;
                    //::std::cout << ov << ::std::endl;
                    q.push(chain_it->first);
                }else{
                    if(chain_it != chain_it_2 && ov>=(ov_perc*chain_it_2->second.length())/100){
                        //::std::cout << "Chain_it_2 sub-node of Chain_it" << ::std::endl;
                        //::std::cout << "Chain_it " << chain_it->second << ::std::endl;
                        //::std::cout << "Chain_it_2 " <<chain_it_2->second << ::std::endl;
                        //::std::cout << ov << ::std::endl;
                        q.push(chain_it_2->first);
                    }
                }
            }
        }
    }

    for(unsigned int i=0; i<short_blocks.size(); ++i){
        bool sub_seq = false;
        for(unsigned int k=0; k<short_blocks.size(); ++k){
            if(short_blocks[i].frag == short_blocks[k].frag && i<k){
                links_pair erased_links;
                erased_links.D_chain = short_blocks[i].frag_links.D_chain;
                erased_links.A_chain = short_blocks[i].frag_links.A_chain;
                short_blocks[k].other_links.push_back(erased_links);
                sub_seq = true;
            }
            if(i!=k && (::seqan::length(short_blocks[i].frag)) < (::seqan::length(short_blocks[k].frag))){
                Finder<CharString> finder(short_blocks[k].frag);
                Pattern<CharString, ShiftAnd> pattern(short_blocks[i].frag);
                if(find(finder,pattern)){
                    links_pair erased_links;
                    erased_links.D_chain = short_blocks[i].frag_links.D_chain;
                    erased_links.A_chain = short_blocks[i].frag_links.A_chain;
                    //::std::cout << i << k << " - " << beginPosition(finder) << " " << endPosition(finder) << ::std::endl;
                    short_blocks[k].other_links.push_back(erased_links);
                    sub_seq = true;
                }
            }
        }
        if(sub_seq){
            s.push(i);
        }
    }

    while(!s.empty()){
        short_blocks.erase(short_blocks.begin()+s.top());
        s.pop();
    }
    while(!q.empty()){
        chains.erase(q.front());
        q.pop();
    }

    for(unsigned int i=0; i<short_blocks.size(); ++i){
        //::std::cout << short_blocks[i].frag << " " << length(short_blocks[i].frag) << ::std::endl; 
//.........这里部分代码省略.........
开发者ID:hjanime,项目名称:RNA-seq-Graph,代码行数:101,代码来源:graph_refinement.cpp

示例14: network_interface_to_ip

bool
network_interface_to_ip(char const *interface_param_name,char const *interface_pattern,std::string &ip,std::set< std::string > *network_interface_ips)
{
	ASSERT( interface_pattern );
	if( !interface_param_name ) {
		interface_param_name = "";
	}

	if( network_interface_ips ) {
		network_interface_ips->clear();
	}

	condor_sockaddr addr;
	if (addr.from_ip_string(interface_pattern)) {
		ip = interface_pattern;
		if( network_interface_ips ) {
			network_interface_ips->insert( ip );
		}

		dprintf(D_HOSTNAME,"%s=%s, so choosing IP %s\n",
				interface_param_name,
				interface_pattern,
				ip.c_str());

		return true;
	}

	StringList pattern(interface_pattern);

	std::string matches_str;
	std::vector<NetworkDeviceInfo> dev_list;
	std::vector<NetworkDeviceInfo>::iterator dev;

	sysapi_get_network_device_info(dev_list);

		// Order of preference:
		//   * non-private IP
		//   * private IP (e.g. 192.168.*)
		//   * loopback
		// In case of a tie, choose the first device in the list.

	int best_so_far = -1;

	for(dev = dev_list.begin();
		dev != dev_list.end();
		dev++)
	{
		bool matches = false;
		if( strcmp(dev->name(),"")!=0 &&
			pattern.contains_anycase_withwildcard(dev->name()) )
		{
			matches = true;
		}
		else if( strcmp(dev->IP(),"")!=0 &&
				 pattern.contains_anycase_withwildcard(dev->IP()) )
		{
			matches = true;
		}

		if( !matches ) {
			dprintf(D_HOSTNAME,"Ignoring network interface %s (%s) because it does not match %s=%s.\n",
					dev->name(), dev->IP(), interface_param_name, interface_pattern);
			continue;
		}

		condor_sockaddr this_addr;
		if (!this_addr.from_ip_string(dev->IP())) {
		//if( !is_ipaddr_no_wildcard(dev->IP(),&this_sin_addr) ) {
			dprintf(D_HOSTNAME,"Ignoring network interface %s (%s) because it does not have a useable IP address.\n",
					dev->name(), dev->IP());
			continue;
		}

		if( matches_str.size() ) {
			matches_str += ", ";
		}
		matches_str += dev->name();
		matches_str += " ";
		matches_str += dev->IP();

		if( network_interface_ips ) {
			network_interface_ips->insert( dev->IP() );
		}

		int desireability;

		if (this_addr.is_loopback()) {
			desireability = 1;
		}
		else if (this_addr.is_private_network()) {
			desireability = 2;
		}
		else {
			desireability = 3;
		}

		if(dev->is_up()) { desireability *= 10; }

		//dprintf(D_HOSTNAME, "Considering %s (Ranked at %d) as possible local hostname versus %s (%d)\n", addr.to_ip_string().Value(), desireability, ip.c_str(), desireability);

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

示例15: _

/*** Trigger a quote download ***/
bool mmStocksPanel::onlineQuoteRefresh(wxString& sError)
{
    if(listCtrlAccount_->m_stocks.size() < 1)
    {
        sError = _("Nothing to update");
        return false;
    }

    //Symbol, (Amount, Name)
    std::map<wxString, std::pair<double, wxString> > stocks_data;
    wxString site = "";

    for (const auto &stock : listCtrlAccount_->m_stocks)
    {
        const wxString symbol = stock.SYMBOL.Upper();
        if (!symbol.IsEmpty())
        {
            if (stocks_data.find(symbol) == stocks_data.end())
            {
                stocks_data[symbol] = std::make_pair(stock.CURRENTPRICE, "");
                site << symbol << "+";
            }
        }
    }
    if (site.Right(1).Contains("+")) site.RemoveLast(1);

    //Sample: http://finance.yahoo.com/d/quotes.csv?s=SBER.ME+GAZP.ME&f=sl1c4n&e=.csv
    //Sample CSV: "SBER.ME",85.49,"RUB","SBERBANK"
    site = wxString::Format(mmex::weblink::YahooQuotes, site);

    refresh_button_->SetBitmapLabel(wxBitmap(wxImage(led_yellow_xpm).Scale(16,16)));
    stock_details_->SetLabelText(_("Connecting..."));
    wxString sOutput;

    int err_code = site_content(site, sOutput);
    if (err_code != wxURL_NOERR)
    {
        sError = sOutput;
        return false;
    }

    //--//
    wxString StockSymbolWithSuffix, sName, StockQuoteCurrency;
    double dPrice = 0.0;

    wxStringTokenizer tkz(sOutput, "\r\n");
    while (tkz.HasMoreTokens())
    {
        const wxString csvline = tkz.GetNextToken();
        StockSymbolWithSuffix = "";
        StockQuoteCurrency = "";
        wxRegEx pattern("\"([^\"]+)\",([^,][0-9.]+),\"([^\"]*)\",\"([^\"]*)\"");
        if (pattern.Matches(csvline))
        {
            StockSymbolWithSuffix = pattern.GetMatch(csvline, 1);
            pattern.GetMatch(csvline, 2).ToDouble(&dPrice);
            StockQuoteCurrency = pattern.GetMatch(csvline, 3);
            sName = pattern.GetMatch(csvline, 4);
        }

        bool updated = !StockSymbolWithSuffix.IsEmpty();

        /* HACK FOR GBP
        http://sourceforge.net/p/moneymanagerex/bugs/414/
        http://sourceforge.net/p/moneymanagerex/bugs/360/
        1. If the share has GBp as currency, its downloaded value in pence
        2. If the share has another currency, we don't need to modify the price
        */

        if (updated && dPrice > 0)
        {
            if (StockQuoteCurrency == "GBp")
                dPrice = dPrice / 100;
            stocks_data[StockSymbolWithSuffix].first = dPrice;
            stocks_data[StockSymbolWithSuffix].second = sName;
            sError << wxString::Format(_("%s\t -> %s\n")
                , StockSymbolWithSuffix, wxString::Format("%0.4f", dPrice));
        }
    }

    for (auto &s: listCtrlAccount_->m_stocks)
    {
        std::map<wxString, std::pair<double, wxString> >::const_iterator it = stocks_data.find(s.SYMBOL.Upper());
        if (it == stocks_data.end()) continue;
        dPrice = it->second.first;

        s.CURRENTPRICE = dPrice;
        s.VALUE = dPrice * s.NUMSHARES;
        if (s.STOCKNAME.empty()) s.STOCKNAME = it->second.second;
        Model_Stock::instance().save(&s);
    }

    // Now refresh the display
    int selected_id = -1;
    if (listCtrlAccount_->get_selectedIndex() > -1)
        selected_id = listCtrlAccount_->m_stocks[listCtrlAccount_->get_selectedIndex()].STOCKID;
    listCtrlAccount_->doRefreshItems(selected_id);

    // We are done!
//.........这里部分代码省略.........
开发者ID:afeimsdn,项目名称:moneymanagerex,代码行数:101,代码来源:stockspanel.cpp


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