2 * Copyright (c) 2012 - 2014 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.
18 #include "modifier_decoration_bin_parser.h"
20 #include "put_record.h"
22 BinModifierDecorationParser::BinModifierDecorationParser() {
23 memset(m_modifier_decoration_table, 0x00, sizeof(SclModifierDecoration) * MAX_SCL_MODIFIER_DECORATION_NUM);
24 parser_info_provider = NULL;
27 BinModifierDecorationParser::~BinModifierDecorationParser() {
30 BinModifierDecorationParser*
31 BinModifierDecorationParser::get_instance() {
32 static BinModifierDecorationParser instance;
36 BinModifierDecorationParser::init(const FileStorage& storage, int offset, int size, IParserInfo_Provider* provider) {
37 m_storage.set_str_provider(provider);
38 m_storage.get_storage(storage, offset, size);
39 this->parser_info_provider = provider;
41 parsing_modifier_decoration_table();
44 /* recompute_layout will change the table */
45 PSclModifierDecoration BinModifierDecorationParser::get_modifier_decoration_table() {
46 return m_modifier_decoration_table;
50 BinModifierDecorationParser::parsing_modifier_decoration_table() {
51 PSclModifierDecoration cur = m_modifier_decoration_table;
53 Modifier_decoration_width record_width;
54 set_modifier_decoration_width(*parser_info_provider, record_width);
59 int size = m_storage.get<sint_t>(4);
60 for (int i = 0; i < size; ++i) {
61 cur->valid = (sclboolean)true;
62 m_storage.get<sint_t>(record_width.extract_background);
63 m_storage.get_str(&(cur->name), record_width.name, m_string_collector);
64 for (int m = 0; m < DISPLAYMODE_MAX; ++m) {
65 for (int n = 0; n < KEY_MODIFIER_MAX; ++n) {
66 m_storage.get_str(&(cur->bg_image_path[m][n]), record_width.bg_image_path, m_string_collector);
72 #ifdef __SCL_TXT_DEBUG
73 put_modifier_decoration(DECODE, m_modifier_decoration_table);
78 BinModifierDecorationParser::get_modifier_decoration_id(const char *name )
80 if (name == NULL) return -1;
82 for (int i = 0; i < MAX_SCL_MODIFIER_DECORATION_NUM; ++i) {
83 if ( m_modifier_decoration_table[i].name ) {
84 if ( 0 == strcmp(m_modifier_decoration_table[i].name, name) ) {