Files
winix/templates/indexpatterns.cpp
Tomasz Sowa b984475e49 fixed: index templates and 'change' templates were not cleared when 'reload' function was called
so wrong indexes have been assigned


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@759 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-08-27 03:12:33 +00:00

86 lines
1.2 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "indexpatterns.h"
#include "core/log.h"
void IndexPatterns::SetPatterns(Patterns * ppatterns)
{
patterns = ppatterns;
}
Ezc::Pattern * IndexPatterns::Get(const std::wstring & file, size_t lang)
{
Tab::iterator i = tab.find(file);
if( i == tab.end() )
return 0;
return patterns->Get(i->second.index, lang);
}
void IndexPatterns::Add(const std::wstring & file)
{
std::pair<Tab::iterator, bool> res = tab.insert( std::make_pair(file, Template()) );
Template & tmpl = res.first->second;
// mark the pattern to not delete
tmpl.to_delete = false;
if( res.second )
tmpl.index = patterns->Add(file);
}
void IndexPatterns::MarkAllToDelete()
{
Tab::iterator i;
for(i=tab.begin() ; i!=tab.end() ; ++i)
i->second.to_delete = true;
}
void IndexPatterns::DeleteMarked()
{
Tab::iterator i = tab.begin();
Tab::iterator next;
while( i != tab.end() )
{
next = i;
++next;
if( i->second.to_delete )
{
patterns->Erase(i->second.index);
tab.erase(i);
}
i = next;
}
}
void IndexPatterns::Clear()
{
tab.clear();
}