2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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.
17 #ifndef MSG_PLUGIN_CONFIG_H
18 #define MSG_PLUGIN_CONFIG_H
21 /*==================================================================================================
23 ==================================================================================================*/
30 #include "MsgCppTypes.h"
34 int tokenType; // not defined 0, title: 1, msgtype: 2, libpath: 3
35 char tokenVal[256]; // null-terminated char array
38 MsgPlgToken(char* pstr=NULL) : tokenType(TOK_UNDEFINED)
50 MsgPlgToken& operator = (const MsgPlgToken& rhs)
54 tokenType = rhs.tokenType;
55 strncpy(tokenVal, rhs.tokenVal, 255);
61 int getType() const { return tokenType; } // not defined 0, title: 1, msgtype: 2, libpath: 3
62 const char* getVal(void) const { return tokenVal; }
63 void getVal(CharVector& vec) const { vec.assign(tokenVal, tokenVal+strlen(tokenVal));}
64 int tokenize(char* pStr);
66 enum { TOK_UNDEFINED=0, TOK_PLG_TITLE, TOK_PLG_TYPE, TOK_PLG_PATH };
68 void reset() { tokenType = TOK_UNDEFINED; }
69 operator void*() const {
70 return (tokenType==TOK_UNDEFINED)? NULL:(void*) this;
74 typedef std::vector<MsgPlgToken> MsgPlgTokenVec;
75 typedef std::map<CharVector, MsgPlgTokenVec> MsgConfigMap;
79 MsgConfigMap configMap;
80 void insert(const MsgPlgToken& tokTitle, const MsgPlgToken& tokMsgType, const MsgPlgToken& tokLibPath);
83 MsgPlgConfig(FILE* fp);
85 /* access method for tokens */
86 const CharVector& title(unsigned int pos);// const; // iteration with ith position i=0, .. , itemCount-1
87 inline int titleCount() const { return configMap.size(); }
89 void token(const CharVector& key, unsigned int pos, MsgPlgToken& retTok);// const;
90 void token(int i, unsigned int pos, MsgPlgToken& retTok);// const;
91 int tokenCount(const CharVector& key) { return configMap[key].size(); } // const leads to error why?
94 #endif // MSG_PLUGIN_CONFIG_H