src/CLIParser.h
branchv_0
changeset 26 cf57e8c78492
parent 19 e4558df9ba2d
child 35 eafffeea6a3e
equal deleted inserted replaced
25:13a1e1134797 26:cf57e8c78492
    29 namespace tr {
    29 namespace tr {
    30 namespace awk {
    30 namespace awk {
    31 
    31 
    32 /**
    32 /**
    33  * This tr-awk CLI options are inspired by tr-guile options.
    33  * This tr-awk CLI options are inspired by tr-guile options.
    34  * These configurations are independent and might diverge, but when possible, the should share same option names and same logic for common parts.
    34  * These configurations are independent and might diverge, but when possible, they should share same option names and same logic for common parts.
    35  */
    35  */
    36 class CLIParser {
    36 class CLIParser {
    37 private:
    37 private:
    38 
    38 
    39 	// FIXME: move common methods/classes to relpipe-lib-cli or relpipe-lib-helper
    39 	// FIXME: move common methods/classes to relpipe-lib-cli or relpipe-lib-helper
    62 
    62 
    63 	static const string_t OPTION_RELATION;
    63 	static const string_t OPTION_RELATION;
    64 	static const string_t OPTION_OUTPUT_ATTRIBUTE;
    64 	static const string_t OPTION_OUTPUT_ATTRIBUTE;
    65 	static const string_t OPTION_INPUT_ATTRIBUTES_APPEND;
    65 	static const string_t OPTION_INPUT_ATTRIBUTES_APPEND;
    66 	static const string_t OPTION_INPUT_ATTRIBUTES_PREPEND;
    66 	static const string_t OPTION_INPUT_ATTRIBUTES_PREPEND;
       
    67 	static const string_t OPTION_DEBUG_VARIABLE_MAPPING;
    67 	static const string_t OPTION_BEFORE_RECORDS;
    68 	static const string_t OPTION_BEFORE_RECORDS;
    68 	static const string_t OPTION_AFTER_RECORDS;
    69 	static const string_t OPTION_AFTER_RECORDS;
    69 	static const string_t OPTION_FOR_EACH;
    70 	static const string_t OPTION_FOR_EACH;
    70 	static const string_t OPTION_DROP;
    71 	static const string_t OPTION_DROP;
    71 	static const string_t OPTION_DEFINE;
    72 	static const string_t OPTION_DEFINE;
    81 			else if (option == OPTION_AFTER_RECORDS) currentRelation.awkAfterRecords = readNext(arguments, i);
    82 			else if (option == OPTION_AFTER_RECORDS) currentRelation.awkAfterRecords = readNext(arguments, i);
    82 			else if (option == OPTION_FOR_EACH) currentRelation.awkForEach = readNext(arguments, i);
    83 			else if (option == OPTION_FOR_EACH) currentRelation.awkForEach = readNext(arguments, i);
    83 			else if (option == OPTION_DROP) currentRelation.drop = true;
    84 			else if (option == OPTION_DROP) currentRelation.drop = true;
    84 			else if (option == OPTION_INPUT_ATTRIBUTES_APPEND) currentRelation.inputAttributesAppend = true;
    85 			else if (option == OPTION_INPUT_ATTRIBUTES_APPEND) currentRelation.inputAttributesAppend = true;
    85 			else if (option == OPTION_INPUT_ATTRIBUTES_PREPEND) currentRelation.inputAttributesPrepend = true;
    86 			else if (option == OPTION_INPUT_ATTRIBUTES_PREPEND) currentRelation.inputAttributesPrepend = true;
       
    87 			else if (option == OPTION_DEBUG_VARIABLE_MAPPING) currentRelation.debugVariableMapping = true;
    86 			else if (option == OPTION_RELATION) {
    88 			else if (option == OPTION_RELATION) {
    87 				addRelation(c, currentRelation); // previous relation
    89 				addRelation(c, currentRelation); // previous relation
    88 				currentRelation.relation = readNext(arguments, i);
    90 				currentRelation.relation = readNext(arguments, i);
    89 			} else if (option == OPTION_OUTPUT_ATTRIBUTE) {
    91 			} else if (option == OPTION_OUTPUT_ATTRIBUTE) {
    90 				relpipe::writer::AttributeMetadata attribute;
    92 				relpipe::writer::AttributeMetadata attribute;
   111 
   113 
   112 const string_t CLIParser::OPTION_RELATION = L"--relation";
   114 const string_t CLIParser::OPTION_RELATION = L"--relation";
   113 const string_t CLIParser::OPTION_OUTPUT_ATTRIBUTE = L"--output-attribute";
   115 const string_t CLIParser::OPTION_OUTPUT_ATTRIBUTE = L"--output-attribute";
   114 const string_t CLIParser::OPTION_INPUT_ATTRIBUTES_APPEND = L"--input-attributes-append";
   116 const string_t CLIParser::OPTION_INPUT_ATTRIBUTES_APPEND = L"--input-attributes-append";
   115 const string_t CLIParser::OPTION_INPUT_ATTRIBUTES_PREPEND = L"--input-attributes-prepend";
   117 const string_t CLIParser::OPTION_INPUT_ATTRIBUTES_PREPEND = L"--input-attributes-prepend";
       
   118 const string_t CLIParser::OPTION_DEBUG_VARIABLE_MAPPING = L"--debug-variable-mapping";
   116 const string_t CLIParser::OPTION_BEFORE_RECORDS = L"--before-records";
   119 const string_t CLIParser::OPTION_BEFORE_RECORDS = L"--before-records";
   117 const string_t CLIParser::OPTION_AFTER_RECORDS = L"--after-records";
   120 const string_t CLIParser::OPTION_AFTER_RECORDS = L"--after-records";
   118 const string_t CLIParser::OPTION_FOR_EACH = L"--for-each";
   121 const string_t CLIParser::OPTION_FOR_EACH = L"--for-each";
   119 const string_t CLIParser::OPTION_DROP = L"--drop";
   122 const string_t CLIParser::OPTION_DROP = L"--drop";
   120 const string_t CLIParser::OPTION_DEFINE = L"--define";
   123 const string_t CLIParser::OPTION_DEFINE = L"--define";