2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file wrt_powder_info_util.h
18 * @author Justyna Mejzner (j.kwiatkowsk@samsung.com)
22 #include "wrt_powder_info_util.h"
23 #include <dpl/singleton_impl.h>
24 IMPLEMENT_SINGLETON(PowderInfoUtil)
26 PowderInfoUtil::PowderInfoUtil()
28 m_categories[DPL::FromUTF8String("nu")] = "Nudity";
29 m_categories[DPL::FromUTF8String("se")] = "Sex";
30 m_categories[DPL::FromUTF8String("vi")] = "Violence";
31 m_categories[DPL::FromUTF8String("la")] = "Potentially offensive language";
32 m_categories[DPL::FromUTF8String("dr")] = "Drug use";
33 m_categories[DPL::FromUTF8String("ga")] = "Gambling";
34 m_categories[DPL::FromUTF8String("ha")] = "Hate or harmful activities";
35 m_categories[DPL::FromUTF8String("ug")] = "Use of user-generated content";
37 m_contexts[DPL::FromUTF8String("xa")] = "This material appears in"
38 " an artistic conteaxt";
39 m_contexts[DPL::FromUTF8String("xb")] = "This material appears in"
40 " an educational context";
41 m_contexts[DPL::FromUTF8String("xc")] = "This material appears in"
43 m_contexts[DPL::FromUTF8String("xd")] = "This material appears in"
45 m_contexts[DPL::FromUTF8String("xe")] = "This material appears in"
49 std::string PowderInfoUtil::getCategoryLabel(const DPL::String &category) const
51 CategoryMap::const_iterator categoryIterator = m_categories.find(category);
52 if (categoryIterator == m_categories.end()) {
53 ThrowMsg(PowderException::IncorrectTypeError,
54 "Wrong type of category.");
56 return categoryIterator->second;
59 std::string PowderInfoUtil::getContextLabel(const DPL::String &context) const
61 ContextMap::const_iterator contextIterator = m_contexts.find(context);
62 if (contextIterator == m_contexts.end()) {
63 ThrowMsg(PowderException::IncorrectTypeError, "Wrong type of context.");
65 return contextIterator->second;