1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 #include "SSMInterface/SSMCore.h"
24 #include "Common/PlatformLayer.h"
25 #include "EvaluationEngine.h"
30 #define INDEX_ALL 9999
33 enum SORT {Command, Context, Property, And_or, Condi, Value};
41 enum ModelCondition::Predicate condition;
44 std::vector<Token> child_token;
45 ModelProperty model_property;
50 * @brief CQLParser Interface
51 * This class parses ContextQuery Language.
54 * string contextQuery;
55 * CQLParser tokenizer;
56 * tokenizer.Parser(contextQuery, &token);
58 * Copyright 2013 by Samsung Electronics, Inc.,
60 * This software is the confidential and proprietary information
61 * of Samsung Electronics, Inc. ("Confidential Information"). You
62 * shall not disclose such Confidential Information and shall use
63 * it only in accordance with the terms of the license agreement
64 * you entered into with Samsung.
72 * @brief parse ContextQuery
74 * @param [in] std::string input - Entered ContetxQuery
75 * @param [out] Token* root - parsed result
81 bool parse(std::string input, Token *root);
85 * @brief convert lowercase
87 * @param [in] std::string str - Entered string
93 static std::string tolower(std::string str);
96 * @fn check_Query_grammer
97 * @brief check grammer
99 * @param [in] Token* token - parsed token
105 bool check_grammer(Token *token);
110 * @brief split sentence
112 * @param [in] const std::string& input - Entered ContetxQuery
113 * @return std::vector<std::string>
118 std::vector<std::string> tokenize(const std::string &input);
122 * @brief this function divides string into tokens based on a delimiter
124 * @param [in] const std::string& str - entered string
125 * @param [in] const std::string& delimiters = " " - token delimiter , default = " "
126 * @return std::vector<std::string>
131 static std::vector<std::string> getTokens(const std::string &str,
132 const std::string &delimiters = " ");
136 * @brief this function checks the index.
138 * @param [in] const std::string input - entered string
139 * @param [out] Token* token - if index exists, The index has been entered into the token.
145 void check_index(std::string input, Token *token);
149 * @brief this function splits the token to the smaller elements.
151 * @param [in] std::string input - entered string
152 * @param [in] Token* root - root token
153 * @param [in] bool flag - flag to distinguish token
154 * @param [in] std::string arg1 - next token, default = ""
155 * @param [in] std::string arg2 - next two token, default = ""
161 bool split(std::string input, Token *root, bool flag, std::string arg1 = "",
162 std::string arg2 = "");
166 * @brief this function distinguishes string type
168 * @param [in] std::string & str - entered string
174 int check_number(std::string &str);
177 * @fn check_Predicate
178 * @brief this function checks predicate
180 * @param [in] std::string input - entered string
181 * @return std::string
186 std::string check_Predicate(std::string input);
189 #endif /*_CQLParser_H_*/