2 * Copyright 2012-2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 "layout_parser_helper.h"
23 const string RotationHelper::pcPortrait = "portrait";
24 const string RotationHelper::pcLandscape = "landscape";
26 const string RotationHelper::toString(const int val) {
36 const int RotationHelper::Int(const string str) {
37 if (str == pcPortrait) {
39 } else if (str == pcLandscape) {
46 ////////////////////////////////////////////////////////////
47 const string PopStyleHelper::pcBase = "base";
48 const string PopStyleHelper::pcPopup = "popup";
49 const string PopStyleHelper::pcPopup_Grab = "popup_grab";
50 const string PopStyleHelper::toString(const int val) {
63 const int PopStyleHelper::Int(const string str) {
66 } else if (str == pcPopup) {
68 } else if (str == pcPopup_Grab) {
75 ///////////////////////////////////////////////////////
77 const string ButtonTypeHelper::pcNormal = "normal";
78 const string ButtonTypeHelper::pcGrab = "grab";
79 const string ButtonTypeHelper::pcSelfish = "selfish";
80 const string ButtonTypeHelper::pcDrag = "drag";
81 const string ButtonTypeHelper::pcMultitap = "multitap";
82 const string ButtonTypeHelper::pcRotation = "rotation";
83 const string ButtonTypeHelper::pcDirection = "direction";
84 const string ButtonTypeHelper::pcRelative_Direction = "relative_direction";
85 const string ButtonTypeHelper::pcUiitem = "uiitem";
87 const string ButtonTypeHelper::toString(const int val) {
103 case RELATIVE_DIRECTION:
104 return pcRelative_Direction;
112 const int ButtonTypeHelper::Int(const string str) {
113 if (str == pcNormal) {
115 } else if (str == pcGrab) {
117 } else if (str == pcSelfish) {
119 } else if (str == pcDrag) {
121 } else if (str == pcMultitap) {
123 } else if (str == pcRotation) {
125 } else if (str == pcDirection) {
127 } else if (str == pcRelative_Direction) {
128 return RELATIVE_DIRECTION;
129 } else if (str == pcUiitem) {
135 ////////////////////////////////////////////////////
136 const string ShiftStateHelper::pcOn = "on";
137 const string ShiftStateHelper::pcOff = "off";
138 const string ShiftStateHelper::pcLoc = "loc";
140 const string ShiftStateHelper::toString(const int val) {
153 const int ShiftStateHelper::Int(const string str) {
156 } else if (str == pcOff) {
158 } else if (str == pcLoc) {
164 /////////////////////////////////////////////////////////
165 const string ButtonStateHelper::pcNormal = "normal";
166 const string ButtonStateHelper::pcPressed = "pressed";
167 const string ButtonStateHelper::pcDisabled = "disabled";
168 const string ButtonStateHelper::toString(const int val) {
180 const int ButtonStateHelper::Int(const string str) {
181 if (str == pcNormal) {
183 } else if (str == pcPressed) {
185 } else if (str == pcDisabled) {
191 ///////////////////////////////////////////////////
192 const string KeyTypeHelper::pcNone = "none";
193 const string KeyTypeHelper::pcChar = "char";
194 const string KeyTypeHelper::pcControl = "control";
195 const string KeyTypeHelper::pcModechange = "modechange";
196 const string KeyTypeHelper::pcString = "string";
197 const string KeyTypeHelper::pcUser = "user";
198 const string KeyTypeHelper::toString(const int val) {
217 const int KeyTypeHelper::Int(const string str) {
220 } else if (str == pcChar) {
222 } else if (str == pcControl) {
224 } else if (str == pcModechange) {
226 } else if (str == pcString) {
228 } else if (str == pcUser) {
234 /////////////////////////////////////////////////////////
235 const string PopupTypeHelper::pcNone = "none";
236 const string PopupTypeHelper::pcBtn_Release_Popup = "release_popup";
237 const string PopupTypeHelper::pcBtn_Release_Popup_Once = "release_popup_once";
238 const string PopupTypeHelper::pcBtn_Press_Popup_Drag = "press_popup_drag";
239 const string PopupTypeHelper::pcLongpress_Popup = "longpress_popup";
240 const string PopupTypeHelper::pcLongpress_Popup_Once = "longpress_popup_once";
241 const string PopupTypeHelper::pcAuto_Popup = "auto_popup";
243 const string PopupTypeHelper::toString(const int val) {
247 case BTN_RELEASE_POPUP:
248 return pcBtn_Release_Popup;
249 case BTN_RELEASE_POPUP_ONCE:
250 return pcBtn_Release_Popup_Once;
251 case BTN_PRESS_POPUP_DRAG:
252 return pcBtn_Press_Popup_Drag;
253 case LONGPRESS_POPUP:
254 return pcLongpress_Popup;
255 case LONGPRESS_POPUP_ONCE:
256 return pcLongpress_Popup_Once;
263 const int PopupTypeHelper::Int(const string str) {
266 } else if (str == pcBtn_Release_Popup) {
267 return BTN_RELEASE_POPUP;
268 } else if (str == pcBtn_Release_Popup_Once) {
269 return BTN_RELEASE_POPUP_ONCE;
270 } else if (str == pcBtn_Press_Popup_Drag) {
271 return BTN_PRESS_POPUP_DRAG;
272 } else if (str == pcLongpress_Popup) {
273 return LONGPRESS_POPUP;
274 } else if (str == pcLongpress_Popup_Once) {
275 return LONGPRESS_POPUP_ONCE;
276 } else if (str == pcAuto_Popup) {
282 ////////////////////////////////////////////////////////
283 const string DragStateHelper::pcNone = "none";
284 const string DragStateHelper::pcLeft = "left";
285 const string DragStateHelper::pcRight = "right";
286 const string DragStateHelper::pcUp = "up";
287 const string DragStateHelper::pcDown = "down";
288 const string DragStateHelper::pcInvalid = "invalid";
289 const string DragStateHelper::pcReturn = "return";
291 const string DragStateHelper::toString(const int val) {
312 const int DragStateHelper::Int(const string str) {
315 } else if (str == pcLeft) {
317 } else if (str == pcRight) {
319 } else if (str == pcUp) {
321 } else if (str == pcDown) {
323 } else if (str == pcInvalid) {
325 } else if (str == pcReturn) {
331 /////////////////////////////////////////////////////////////
332 const string ExtraOptionHelper::pcOption_4_directions = "4-directions";
333 const string ExtraOptionHelper::pcOption_8_directions = "8-directions";
334 const string ExtraOptionHelper::pcOption_4_directions_long = "4-directions-long";
335 const string ExtraOptionHelper::pcOption_8_directions_long = "8-directions-long";
336 const string ExtraOptionHelper::pcOption_4_directions_return = "4-directions-return";
337 const string ExtraOptionHelper::pcOption_8_directions_return = "8-directions-return";
338 const string ExtraOptionHelper::pcOption_4_directions_return_curve = "4-directions-return-curve";
340 const string ExtraOptionHelper::toString(const int val) {
342 case OPTION_4_DIRECTIONS:
343 return pcOption_4_directions;
344 case OPTION_8_DIRECTIONS:
345 return pcOption_8_directions;
346 case OPTION_4_DIRECTIONS_LONG:
347 return pcOption_4_directions_long;
348 case OPTION_8_DIRECTIONS_LONG:
349 return pcOption_8_directions_long;
350 case OPTION_4_DIRECTIONS_RETURN:
351 return pcOption_4_directions_return;
352 case OPTION_8_DIRECTIONS_RETURN:
353 return pcOption_8_directions_return;
354 case OPTION_4_DIRECTIONS_RETURN_CURVE:
355 return pcOption_4_directions_return_curve;
357 return pcOption_4_directions;
360 const int ExtraOptionHelper::Int(const string str) {
361 if (str == pcOption_4_directions) {
362 return OPTION_4_DIRECTIONS;
363 } else if (str == pcOption_8_directions) {
364 return OPTION_8_DIRECTIONS;
365 } else if (str == pcOption_4_directions_long) {
366 return OPTION_4_DIRECTIONS_LONG;
367 } else if (str == pcOption_8_directions_long) {
368 return OPTION_8_DIRECTIONS_LONG;
369 } else if (str == pcOption_4_directions_return) {
370 return OPTION_4_DIRECTIONS_RETURN;
371 } else if (str == pcOption_8_directions_return) {
372 return OPTION_8_DIRECTIONS_RETURN;
373 } else if (str == pcOption_4_directions_return_curve) {
374 return OPTION_4_DIRECTIONS_RETURN_CURVE;
376 return OPTION_4_DIRECTIONS;
379 /////////////////////////////////////////////////////////////////////////////
380 const string MultitouchTypeHelper::pcExclusive = "exclusive";
381 const string MultitouchTypeHelper::pcCooperative = "cooperative";
382 const string MultitouchTypeHelper::pcGrab_Sub_Events = "grab_sub_events";
384 const string MultitouchTypeHelper::toString(const int val) {
389 return pcCooperative;
390 case GRAB_SUB_EVENTS:
391 return pcGrab_Sub_Events;
396 const int MultitouchTypeHelper::Int(const string str) {
397 if (str == pcExclusive) {
399 } else if (str == pcCooperative) {
401 } else if (str == pcGrab_Sub_Events) {
402 return GRAB_SUB_EVENTS;
407 ////////////////////////////////////////////////////
408 const string BOOLTypeHelper::pcTrue = "true";
409 const string BOOLTypeHelper::pcFalse = "false";
411 const string BOOLTypeHelper::toString(const bool val) {
412 if (val) return pcTrue;
415 const int BOOLTypeHelper::Bool(const string str) {
416 if (str == pcFalse) {
418 } else if (str == pcTrue) {
424 /////////////////////////////////////////////////
425 const string INTTypeHelper::dextoString(const int val) {
427 sprintf(temp, "0x%x", val);
430 const string INTTypeHelper::toString(const int val) {
432 sprintf(temp, "%d", val);
435 const int INTTypeHelper::Int(const string str) {
437 sscanf(str.c_str(), "%d", &val);
440 const int INTTypeHelper::dexInt(const string str) {
442 sscanf(str.c_str(), "%x", &val);