//#pragma optimize( "", on )
void CTrieHolder::Create(const yset< CWorkRule >& Patterns, const SymbolInformationType* Info)
{
    m_pSymbolInformation = Info;
    m_AlphabetSize = m_pSymbolInformation->size();

    CreateTrie(Patterns);
    InitFailureFunction();
};
Example #2
0
int Techniques::Static::AhoCorasick::LoadDB(void)
{
	std::fstream Version;
	float DB_ver, ADB_ver, core_ver, gui_ver;

	Version.open(VersionPath, std::fstream::in | std::fstream::out); //version.dat needs to be updated every time signature DB is updated

	if (!Version.is_open())
	{
		std::cerr << "[-] Couldn't check for Database version." << std::endl;
		return 1;
	}

	Version >> core_ver >> gui_ver >> DB_ver >> ADB_ver;

	Version.clear(); //c++ standards prevents outputing after inputing directly
	Version.seekp(0);


	if (DB_ver != ADB_ver) //Trie database isn't updated up to signatures database
	{
		CreateTrie();
		

		if (!SavingTrie()) //No error occured while saving database
		{
			ADB_ver = DB_ver;
			Version << core_ver << gui_ver << DB_ver << ADB_ver; //trie database became updated so both version are the same
			Version.close();
		}

		else
		{
			std::cerr << "[-] Failed to save database." << std::endl;
			Version.close();
			return 1;
		}
	}

	else //Trie database is well updated
	{
		if (LoadingTrie()) //error occured while loading database
		{
			std::cerr << "[-] Failed to load database." << std::endl;
			Version.close();
			return 1;
		}
		Version.close();
	}

	return 0;

}
Example #3
0
 Trie(const std::vector<Unicode>& keys, const std::vector<const DictUnit*>& valuePointers) {
   CreateTrie(keys, valuePointers);
 }