-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdictionary.cpp
More file actions
35 lines (26 loc) · 869 Bytes
/
dictionary.cpp
File metadata and controls
35 lines (26 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "stdafx.h"
#include "binarylexeme.h"
#include "dictionary.h"
namespace bpatch
{
std::unique_ptr<AbstractBinaryLexeme>& Dictionary::Lexeme(const std::string_view aname) const
{
if (auto it = dict.find(aname); it != dict.cend())
{
return *it->second;
}
return const_cast<std::unique_ptr<AbstractBinaryLexeme>&>(empty_result);
}
AbstractLexemesPair Dictionary::LexemesPair(const std::string_view anameSrc, const std::string_view anameTrg) const
{
return {Lexeme(anameSrc), Lexeme(anameTrg)};
}
bool Dictionary::AddBinaryLexeme(const std::string_view aname, std::unique_ptr<AbstractBinaryLexeme>&& alexeme)
{
auto it = lexemes_.emplace(lexemes_.cend(), std::move(alexeme));
auto [it_ignore, added] = dict.insert(
std::pair<std::string_view, LEXEMES_HOLDER::iterator>(
aname, it));
return added;
}
};