| 1 | /* -*- c-basic-offset: 2 -*- */ | 
|---|
| 2 | /* | 
|---|
| 3 | Copyright(C) 2011-2013 Kentoku SHIBA | 
|---|
| 4 | Copyright(C) 2011-2013 Kouhei Sutou <kou@clear-code.com> | 
|---|
| 5 |  | 
|---|
| 6 | This library is free software; you can redistribute it and/or | 
|---|
| 7 | modify it under the terms of the GNU Lesser General Public | 
|---|
| 8 | License as published by the Free Software Foundation; either | 
|---|
| 9 | version 2.1 of the License, or (at your option) any later version. | 
|---|
| 10 |  | 
|---|
| 11 | This library is distributed in the hope that it will be useful, | 
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 14 | Lesser General Public License for more details. | 
|---|
| 15 |  | 
|---|
| 16 | You should have received a copy of the GNU Lesser General Public | 
|---|
| 17 | License along with this library; if not, write to the Free Software | 
|---|
| 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | 
|---|
| 19 | */ | 
|---|
| 20 |  | 
|---|
| 21 | #ifndef MRN_PARAMETERS_PARSER_HPP_ | 
|---|
| 22 | #define MRN_PARAMETERS_PARSER_HPP_ | 
|---|
| 23 |  | 
|---|
| 24 | #include <mrn_mysql.h> | 
|---|
| 25 | #include <my_list.h> | 
|---|
| 26 |  | 
|---|
| 27 | namespace mrn { | 
|---|
| 28 | class ParametersParser { | 
|---|
| 29 | public: | 
|---|
| 30 | ParametersParser(const char *input, unsigned int input_length); | 
|---|
| 31 | ~ParametersParser(); | 
|---|
| 32 | void parse(); | 
|---|
| 33 | const char *operator[](const char *key); | 
|---|
| 34 |  | 
|---|
| 35 | private: | 
|---|
| 36 | const char *input_; | 
|---|
| 37 | unsigned int input_length_; | 
|---|
| 38 |  | 
|---|
| 39 | LIST *parameters_; | 
|---|
| 40 |  | 
|---|
| 41 | bool is_white_space(char character) { | 
|---|
| 42 | switch (character) { | 
|---|
| 43 | case ' ': | 
|---|
| 44 | case '\r': | 
|---|
| 45 | case '\n': | 
|---|
| 46 | case '\t': | 
|---|
| 47 | return true; | 
|---|
| 48 | break; | 
|---|
| 49 | default: | 
|---|
| 50 | return false; | 
|---|
| 51 | break; | 
|---|
| 52 | } | 
|---|
| 53 | }; | 
|---|
| 54 | const char *parse_value(const char *current, const char *end, | 
|---|
| 55 | const char *key, unsigned int key_length); | 
|---|
| 56 | }; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | #endif /* MRN_PARAMETERS_PARSER_HPP_ */ | 
|---|
| 60 |  | 
|---|