forked from yvt/xtbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
XTBDictionaryType.cpp
32 lines (28 loc) · 1.03 KB
/
XTBDictionaryType.cpp
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
//
// XTBDictionaryType.cpp
// XTBook
//
// Created by Kawada Tomoaki on 5/22/11.
// Copyright 2011 Nexhawks. All rights reserved.
//
#include "XTBDictionaryType.h"
#include <map>
#include "XTBException.h"
static std::map<std::wstring, XTBDictionaryType *> g_dictionaryTypes;
void XTBDictionaryType::registerDictionaryType(XTBDictionaryType *factory){
std::map<std::wstring, XTBDictionaryType *>::iterator it=g_dictionaryTypes.find(factory->identifier());
if(it==g_dictionaryTypes.end()){
// no duplication. we can add it.
g_dictionaryTypes[factory->identifier()]=factory;
}else{
XTBThrowException(L"XTBDictionaryTypeAlreadyExistException", factory->identifier().c_str(), NULL);
}
}
const XTBDictionaryType *XTBDictionaryType::dictionaryTypeWithIdentifier(std::wstring const & identifier){
std::map<std::wstring, XTBDictionaryType *>::iterator it=g_dictionaryTypes.find(identifier);
if(it==g_dictionaryTypes.end()){
XTBThrowException(L"XTBDictionaryTypeNotFoundException", identifier.c_str(), NULL);
}else{
return it->second;
}
}