summaryrefslogtreecommitdiff
path: root/l10ntools/source
diff options
context:
space:
mode:
Diffstat (limited to 'l10ntools/source')
-rw-r--r--l10ntools/source/merge.cxx99
1 files changed, 11 insertions, 88 deletions
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index a86ddf96124e..ea236948b8b8 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -107,74 +107,6 @@ OString MergeEntrys::GetQTZText(const ResData& rResData, const OString& rOrigTex
return sKey + GetDoubleBars() + rOrigText;
}
-
-// class MergeDataHashMap
-
-
-std::pair<MergeDataHashMap::iterator,bool> MergeDataHashMap::insert(const OString& rKey, MergeData* pMergeData)
-{
- std::pair<iterator,bool> aTemp = m_aHashMap.emplace( rKey, pMergeData );
- if( m_aHashMap.size() == 1 )
- {
- // When first insert, set an iterator to the first element
- aFirstInOrder = aTemp.first;
- }
- else
- {
- // Define insertion order by setting an iterator to the next element.
- aLastInsertion->second->m_aNextData = aTemp.first;
- }
- aLastInsertion = aTemp.first;
- return aTemp;
-}
-
-MergeDataHashMap::iterator const & MergeDataHashMap::find(const OString& rKey)
-{
- iterator aHint = m_aHashMap.end();
-
- // Add a hint
- if( bFirstSearch && !m_aHashMap.empty() )
- {
- aHint = aFirstInOrder;
- }
- else if( aLastFound == aLastInsertion )
- {
- // Next to the last element is the first element
- aHint = aFirstInOrder;
- }
- else if( aLastFound != m_aHashMap.end() && aLastFound != aLastInsertion )
- {
- aHint = aLastFound->second->m_aNextData;
- }
-
- // If hint works than no need for search
- if( aHint != m_aHashMap.end() && aHint->first == rKey )
- {
- aLastFound = aHint;
- }
- else
- {
- aLastFound = m_aHashMap.find(rKey);
- }
-
- bFirstSearch = false;
- return aLastFound;
-}
-
-
-// class MergeData
-
-
-MergeData::MergeData()
- : pMergeEntrys( new MergeEntrys() )
-{
-}
-
-MergeData::~MergeData()
-{
-}
-
-
// class MergeDataFile
@@ -296,8 +228,6 @@ MergeDataFile::MergeDataFile(
MergeDataFile::~MergeDataFile()
{
- for (MergeDataHashMap::iterator aI = aMap.begin(), aEnd = aMap.end(); aI != aEnd; ++aI)
- delete aI->second;
}
std::vector<OString> MergeDataFile::GetLanguages() const
@@ -305,7 +235,7 @@ std::vector<OString> MergeDataFile::GetLanguages() const
return std::vector<OString>(aLanguageSet.begin(),aLanguageSet.end());
}
-MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive )
+MergeEntrys *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive )
{
OString sOldG = pResData->sGId;
OString sOldL = pResData->sId;
@@ -320,12 +250,12 @@ MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive
OString sKey = CreateKey( pResData->sResTyp , pResData->sGId , pResData->sId , pResData->sFilename , bCaseSensitive );
- MergeDataHashMap::const_iterator mit = aMap.find( sKey );
+ auto mit = aMap.find( sKey );
if(mit != aMap.end())
{
pResData->sGId = sOldG;
pResData->sId = sOldL;
- return mit->second;
+ return mit->second.get();
}
pResData->sGId = sOldG;
pResData->sId = sOldL;
@@ -335,19 +265,13 @@ MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive
MergeEntrys *MergeDataFile::GetMergeEntrys( ResData *pResData )
{
// search for requested MergeEntrys
- MergeData *pData = GetMergeData( pResData );
- if ( pData )
- return pData->GetMergeEntries();
- return nullptr;
+ return GetMergeData( pResData );
}
MergeEntrys *MergeDataFile::GetMergeEntrysCaseSensitive( ResData *pResData )
{
// search for requested MergeEntrys
- MergeData *pData = GetMergeData( pResData , true );
- if ( pData )
- return pData->GetMergeEntries();
- return nullptr;
+ return GetMergeData( pResData , true );
}
void MergeDataFile::InsertEntry(
@@ -357,28 +281,27 @@ void MergeDataFile::InsertEntry(
const OString &rTITLE, const OString &rInFilename,
bool bFirstLang, bool bCaseSensitive )
{
- MergeData *pData = nullptr;
+ MergeEntrys *pMergeEntrys = nullptr;
// search for MergeData
OString sKey = CreateKey(rTYP , rGID , rLID , rInFilename , bCaseSensitive);
if( !bFirstLang )
{
- MergeDataHashMap::const_iterator mit = aMap.find( sKey );
+ auto mit = aMap.find( sKey );
if(mit != aMap.end())
- pData = mit->second;
+ pMergeEntrys = mit->second.get();
}
- if( !pData )
+ if( !pMergeEntrys )
{
- pData = new MergeData;
- aMap.insert( sKey, pData );
+ pMergeEntrys = new MergeEntrys;
+ aMap.emplace( sKey, std::unique_ptr<MergeEntrys>(pMergeEntrys) );
}
// insert the cur string
- MergeEntrys *pMergeEntrys = pData->GetMergeEntries();
if( nLANG =="qtz" )
{
const OString sTemp = rInFilename + rGID + rLID + rTYP;