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


C++ HashString函数代码示例

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


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

示例1: fopen

void JStringServer::ExtractStrings()
{
    FILE* fp = fopen( "strings.txt", "wt" );
    if (!fp)
    {
        return;
    }
    m_Dictionary.clear();

    //  extract text strings
    JObjectIterator it( JCore::s_pInstance );
    JString val, hash;
    while (it)
    {
        JObject* pObj = *it;
        if (pObj->HasName( "system" ))
        {
            it.breadth_next();
            continue;
        }
        ++it;
        bool bRes = pObj->GetProperty( "text", val );
        if (!bRes || val.size() == 0 || val[0] == '#')
        {
            continue;
        }
        if (!HasCyrillics( val.c_str() ))
        {
            continue;
        }
        HashString( val.c_str(), hash );
        JStringDictionary::iterator location = m_Dictionary.find( hash );

        JString taggedHash = "#";
        taggedHash += hash;
        pObj->SetProperty( "text", taggedHash.c_str() );

        if (location != m_Dictionary.end())
        {
            if (val == (*location).second)
            {
                continue;
            }
            assert( false );
        }
        fprintf( fp, "%s %s\n", hash.c_str(), val.c_str() );
        m_Dictionary[hash] = val;
    }
    fclose( fp );

    //  save scripts
    g_pPersistServer->SaveScripts();
}
开发者ID:skopp,项目名称:rush,代码行数:53,代码来源:jstringserver.cpp

示例2: HashString

// Static function
uint CElement::GetTypeHashFromString ( const SString& strTypeName )
{
    // Standard types use unique index upto EElementType::UNKNOWN
    EElementType elementType;
    if ( StringToEnum ( strTypeName, elementType ) )
        return elementType;

    // Custom types use name hash.  TODO: Make it use a unique index instead
    uint uiTypeHash = HashString ( strTypeName );
    uiTypeHash = ( uiTypeHash % 0xFFFFFF00 ) + CElement::UNKNOWN + 1;
    return uiTypeHash;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:13,代码来源:CElement.cpp

示例3: Translate_Dump

//*****************************************************************************
//
//*****************************************************************************
void Translate_Dump(const char *string, bool dump)
{
	if(dump)
	{
		FILE * fh = fopen( "hash.txt", "a" );
		if(fh)
		{
			fprintf( fh,  "%08x,%s\n", HashString(string), string );
			fclose(fh);
		}
	}
}
开发者ID:ThePhoenixRises,项目名称:daedalus,代码行数:15,代码来源:Translate.cpp

示例4: fCookieJar

BUrlContext::BUrlContext()
	: 
	fCookieJar(),
	fAuthenticationMap(NULL)
{
	fAuthenticationMap = new(std::nothrow) BHttpAuthenticationMap();

	// This is the default authentication, used when nothing else is found.
	// The empty string used as a key will match all the domain strings, once
	// we have removed all components.
	fAuthenticationMap->Put(HashString("", 0), new BHttpAuthentication());
}
开发者ID:RAZVOR,项目名称:haiku,代码行数:12,代码来源:UrlContext.cpp

示例5: RebuildLiteralTable

static void
RebuildLiteralTable(
    register LiteralTable *tablePtr)
				/* Local or global table to enlarge. */
{
    LiteralEntry **oldBuckets;
    register LiteralEntry **oldChainPtr, **newChainPtr;
    register LiteralEntry *entryPtr;
    LiteralEntry **bucketPtr;
    const char *bytes;
    int oldSize, count, index, length;

    oldSize = tablePtr->numBuckets;
    oldBuckets = tablePtr->buckets;

    /*
     * Allocate and initialize the new bucket array, and set up hashing
     * constants for new array size.
     */

    tablePtr->numBuckets *= 4;
    tablePtr->buckets = ckalloc(tablePtr->numBuckets * sizeof(LiteralEntry*));
    for (count=tablePtr->numBuckets, newChainPtr=tablePtr->buckets;
	    count>0 ; count--, newChainPtr++) {
	*newChainPtr = NULL;
    }
    tablePtr->rebuildSize *= 4;
    tablePtr->mask = (tablePtr->mask << 2) + 3;

    /*
     * Rehash all of the existing entries into the new bucket array.
     */

    for (oldChainPtr=oldBuckets ; oldSize>0 ; oldSize--,oldChainPtr++) {
	for (entryPtr=*oldChainPtr ; entryPtr!=NULL ; entryPtr=*oldChainPtr) {
	    bytes = TclGetStringFromObj(entryPtr->objPtr, &length);
	    index = (HashString(bytes, length) & tablePtr->mask);

	    *oldChainPtr = entryPtr->nextPtr;
	    bucketPtr = &tablePtr->buckets[index];
	    entryPtr->nextPtr = *bucketPtr;
	    *bucketPtr = entryPtr;
	}
    }

    /*
     * Free up the old bucket array, if it was dynamically allocated.
     */

    if (oldBuckets != tablePtr->staticBuckets) {
	ckfree(oldBuckets);
    }
}
开发者ID:afmayer,项目名称:tcl-tk,代码行数:53,代码来源:tclLiteral.c

示例6: _

//---------------------------- PRIVATE          -----------------------------//
void *wxServerConnectionThread::Entry()
{
	bool valid = true;

	// It's ok to block this thread waiting for data.
	mSocket->SetFlags(wxSOCKET_WAITALL);

	try
	{
		// If we pass the check, but return false, it means we got hit by the
		// site requesting a host check.

		if(false == Cities3DCheck())
		{
            static const wxString stReceivedAHostCheck = _("Received a host check from the site.");
    
			wxRuleEvent event(shNetworkRuleSystemMessage, 
				DataObject(stReceivedAHostCheck, wxDateTime::Now()));
			mHandler->AddPendingEvent(event);

			valid = false;
			goto error;
		}
		VersionCheck();

		ReceiveSpectator();

		SendSpectators();
		SendGame();
		SendRNG();
	}
	catch(const std::exception &e)
	{
		valid = false;

		wxLogDebug(HashString(e.what()).wx_str());
	}

error:
	if(true == valid)
	{
		// This socket is complete and ready for data.
		mSocket->mIsComplete = true;
	}
	else
	{
		mSocket->Destroy();
		mSocket = NULL;
	}

	return NULL;
}
开发者ID:Dangr8,项目名称:Cities3D,代码行数:53,代码来源:ServerConnectionThread.cpp

示例7: ConvertGameRulesToHash

	const uint32 ConvertGameRulesToHash(const char* gameRules)
	{
		if (gameRules && (strlen(gameRules) < 32))
		{
			char lowerRulesName[32];
			NameCRCHelper::MakeLowercase(lowerRulesName, gameRules);
			return HashString(lowerRulesName);
		}
		else
		{
			return 0;
		}
	}
开发者ID:richmondx,项目名称:bare-minimum-cryengine3,代码行数:13,代码来源:GameLobbyData.cpp

示例8: HashString

unsigned long StringHash::Hashed(string lpszString)
{ 
	//不同的字符串三次hash还会碰撞的几率无限接近于不可能
	unsigned long nHash = HashString(lpszString, HASH_OFFSET); 
	unsigned long nHashA = HashString(lpszString, HASH_A); 
	unsigned long nHashB = HashString(lpszString, HASH_B); 
	unsigned long nHashStart = nHash % m_tablelength, 
	nHashPos = nHashStart;

	while ( m_HashIndexTable[nHashPos].bExists) 
	{ 
	if (m_HashIndexTable[nHashPos].nHashA == nHashA && m_HashIndexTable[nHashPos].nHashB == nHashB)
		return nHashPos; 
	else 
		nHashPos = (nHashPos + 1) % m_tablelength;

	if (nHashPos == nHashStart) 
		break; 
	}

	return -1; //没有找到 
}
开发者ID:idovelemon,项目名称:OpenProfiler,代码行数:22,代码来源:StringHash.cpp

示例9: ConvertMapToHash

	const uint32 ConvertMapToHash(const char* mapName)
	{
		if (mapName && (strlen(mapName) < 128))
		{
			char lowerMapName[128];
			NameCRCHelper::MakeLowercase(lowerMapName, mapName);
			return HashString(lowerMapName);
		}
		else
		{
			return 0;
		}
	}
开发者ID:richmondx,项目名称:bare-minimum-cryengine3,代码行数:13,代码来源:GameLobbyData.cpp

示例10: ParseName

DWORD FusionBind::Hash()
{
    DWORD hash = 0;

    // Normalize representation
    if (!m_fParsed)
        ParseName();


    // Hash fields.

    if (m_pAssemblyName)
        hash ^= HashStringA(m_pAssemblyName);
    hash = _rotl(hash, 4);

    hash ^= HashBytes(m_pbPublicKeyOrToken, m_cbPublicKeyOrToken);
    hash = _rotl(hash, 4);
        
    hash ^= m_dwFlags;
    hash = _rotl(hash, 4);

    if (m_CodeInfo.m_pszCodeBase)
        hash ^= HashString(m_CodeInfo.m_pszCodeBase);
    hash = _rotl(hash, 4);

    hash ^= m_context.usMajorVersion;
    hash = _rotl(hash, 8);

    if (m_context.usMajorVersion != (USHORT) -1) {
        hash ^= m_context.usMinorVersion;
        hash = _rotl(hash, 8);
        
        if (m_context.usMinorVersion != (USHORT) -1) {
            hash ^= m_context.usBuildNumber;
            hash = _rotl(hash, 8);
        
            if (m_context.usBuildNumber != (USHORT) -1) {
                hash ^= m_context.usRevisionNumber;
                hash = _rotl(hash, 8);
            }
        }
    }

    if (m_context.szLocale)
        hash ^= HashStringA(m_context.szLocale);
    hash = _rotl(hash, 4);

    hash ^= m_CodeInfo.m_fLoadFromParent;

    return hash;
}
开发者ID:ArildF,项目名称:masters,代码行数:51,代码来源:fusionbind.cpp

示例11: HashString

bool StringHash::Hash(string lpszString)
{  
	const unsigned long HASH_OFFSET = 0, HASH_A = 1, HASH_B = 2;  
	unsigned long nHash = HashString(lpszString, HASH_OFFSET);  
	unsigned long nHashA = HashString(lpszString, HASH_A);  
	unsigned long nHashB = HashString(lpszString, HASH_B);  
	unsigned long nHashStart = nHash % m_tablelength, 
		nHashPos = nHashStart;  

	while ( m_HashIndexTable[nHashPos].bExists)  
	{   
		nHashPos = (nHashPos + 1) % m_tablelength;  
		if (nHashPos == nHashStart)  
		{  
			return false;   
		}  
	}  
	m_HashIndexTable[nHashPos].bExists = true;  
	m_HashIndexTable[nHashPos].nHashA = nHashA;  
	m_HashIndexTable[nHashPos].nHashB = nHashB;  

	return true;  
}  
开发者ID:JakeJesi,项目名称:BloomFilter,代码行数:23,代码来源:StringHash.cpp

示例12: HashString

uint32 Block::fileKey(const string &fileName, const BlockTableEntry &blockTableEntry)
{
	if (fileName.empty())
		throw std::logic_error(_("Never try to get file keys of empty filenames."));

	// Hash the name to get the base key
	uint32 nFileKey = HashString(Mpq::cryptTable(), fileName.c_str(), HashType::FileKey);

	// Offset-adjust the key if necessary
	if (blockTableEntry.flags & Flags::UsesEncryptionKey)
		nFileKey = (nFileKey + blockTableEntry.blockOffset) ^ blockTableEntry.fileSize;

	return nFileKey;
}
开发者ID:CruzR,项目名称:wc3lib,代码行数:14,代码来源:block.cpp

示例13: TESTANDRETURN

HRESULT CeeSectionString::getEmittedStringRef(__in_z LPWSTR target, StringRef *ref)
{
    TESTANDRETURN(ref!=NULL, E_POINTER);
    ULONG hashId = HashString(target) % MaxVirtualEntries;
    ULONG bucketIndex = hashId / MaxRealEntries;

    StringTableEntry *entry;
    entry = findStringInsert(stringTable[bucketIndex], target, hashId);

    if (! entry)
        return E_OUTOFMEMORY;
    *ref = entry->m_offset;
    return S_OK;
}
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:14,代码来源:ceesectionstring.cpp

示例14: resolveTypePrototypes

static void resolveTypePrototypes( void ) {
/*****************************************/

/* adds required protoypes to the protoype section */

    statement   *finger;
    statement   *rc;
    long        len;
    char        *name;
    char        *libname;

    if( !SRU.type_sec ) {
        return;
    }

    finger = SRU.forward_prots;

    /* loop through the chain of prototypes and add them if necessary */
    while( finger ) {
        name = finger->data.sp.name;
        len = strlen( name );

        /* check in hash table for function name */
        if( !FindHashEntry(SRU.type_prots, HashString(name, len), name, len) ) {

            /* add to prototype section */
            rc = insertTypePrototype( finger, SRU.type_sec );
            rc->link = SRU.cpp_prots;
            SRU.cpp_prots = rc;
            rc->keep = TRUE;
            InsertHashValue( SRU.type_prots, rc->data.sp.name,
                             strlen( rc->data.sp.name ), rc );
        }
        finger = finger->link;
    }

    /* generate constructors and destructor prototypes if necessary */
    libname = GetLibName();
    len = max( sizeof( DES_DECL_TEMPLATE ) + strlen( SRU.des_name ),
               sizeof( CONS_DECL_TEMPLATE ) + strlen( SRU.con_name ) );
    name = alloca( len + strlen( libname ) + 1 );
    if( !( SRU.flags & DESTRUCTOR_DEFINED ) ) {
        sprintf( name, DES_DECL_TEMPLATE, SRU.des_name, libname );
        insertStatement( SRU.type_sec, name );
    }
    if( !( SRU.flags & CONSTRUCTOR_DEFINED ) ) {
        sprintf( name, CONS_DECL_TEMPLATE, SRU.con_name, libname );
        insertStatement( SRU.type_sec, name );
    }
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:50,代码来源:srusuprt.c

示例15: Ins3Hashmg

///////////////////////////////////////////////////////////
//function: 插入新的元素进入hash表
//parameter:
//author: wuxiaoqi
//time: 2016-3-23
///////////////////////////////////////////////////////////
int Ins3Hashmg(hashtable * HashMg, const char *pmkey, const char * pidkey, int fqv)
{
	int ln;
	const unsigned long HASH_OFFSET = 0, HASH_A = 1, HASH_B = 2;
	unsigned long nHash = HashString(pmkey, HASH_OFFSET);
	unsigned long nHashA = HashString(pmkey, HASH_A);
	unsigned long nHashB = HashString(pmkey, HASH_B);
	unsigned long nHashStart = nHash%DCHASH_SIZE, nHashPos = nHashStart;
	while(((*HashMg)+nHashPos)->bExists)
	{
		nHashPos = (nHashPos + 1)%DCHASH_SIZE;
		if (nHashPos == nHashStart)
			return 0;
	}

	((*HashMg)+nHashPos)->bExists = 1;
	((*HashMg)+nHashPos)->nHashA = nHashA;
	((*HashMg)+nHashPos)->nHashB = nHashB;

    if(pmkey != NULL && *pmkey != 0)
	{
		ln = strlen(pmkey);
		((*HashMg)+nHashPos)->pentityname = (char *)malloc(ln+1);
		strncpy(((*HashMg)+nHashPos)->pentityname, pmkey, ln);
		*(((*HashMg)+nHashPos)->pentityname + ln) = 0;	 
	}
	((*HashMg)+nHashPos)->fqval = fqv;
    ((*HashMg)+nHashPos)->score = 0.0001;
	if(pidkey != NULL && *pidkey != 0)
	{
		ln = strlen(pidkey);
		((*HashMg)+nHashPos)->pidcode = (char *)malloc(ln+1);
		strncpy(((*HashMg)+nHashPos)->pidcode, pidkey, ln);
		*(((*HashMg)+nHashPos)->pidcode + ln) = 0;	 
	}
	return 1;
}
开发者ID:jhz-dongyanan,项目名称:jhz,代码行数:43,代码来源:EntityRecog.cpp


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