Changeset 9

Show
Ignore:
Timestamp:
02/25/07 16:45:56 (2 years ago)
Author:
aarti_pl
Message:

D-isation of function names... Interfaces can still change in future...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/doost/program_options/command_line_parser.d

    r5 r9  
    164164        if (style == 0) style = style_t.default_style; 
    165165 
    166         check_style(style); 
     166        checkStyle(style); 
    167167        m_style = cast(style_t)(style); 
    168168    } 
    169169 
    170     void allow_unregistered() { 
     170    void allowUnregistered() { 
    171171        m_allow_unregistered = true; 
    172172    } 
    173173 
    174     void set_options_description(OptionsDescription desc) { 
     174    void setOptionsDescription(OptionsDescription desc) { 
    175175        m_desc = desc; 
    176176    } 
    177177 
    178178 
    179     void set_positional_options(PositionalOptionsDescription positional) { 
     179    void setPositionalOptions(PositionalOptionsDescription positional) { 
    180180        m_positional = positional; 
    181181    } 
     
    199199 
    200200        if (m_style_parser) style_parsers~=m_style_parser; 
    201         if (m_additional_parser) style_parsers~=&handle_additional_parser; 
    202         if (m_style & style_t.allow_long) style_parsers~=&parse_long_option; 
    203         if ((m_style & style_t.allow_long_disguise)) style_parsers~=&parse_disguised_long_option; 
    204         if ((m_style & style_t.allow_short) && (m_style & style_t.allow_dash_for_short)) style_parsers~=&parse_short_option; 
    205         if ((m_style & style_t.allow_short) && (m_style & style_t.allow_slash_for_short)) style_parsers~=&parse_dos_option; 
    206  
    207         style_parsers~=&parse_terminator; 
     201        if (m_additional_parser) style_parsers~=&handleAdditionalParser; 
     202        if (m_style & style_t.allow_long) style_parsers~=&parseLongOption; 
     203        if ((m_style & style_t.allow_long_disguise)) style_parsers~=&parseDisguisedLongOption; 
     204        if ((m_style & style_t.allow_short) && (m_style & style_t.allow_dash_for_short)) style_parsers~=&parseShortOption; 
     205        if ((m_style & style_t.allow_short) && (m_style & style_t.allow_slash_for_short)) style_parsers~=&parseDosOption; 
     206 
     207        style_parsers~=&parseTerminator; 
    208208 
    209209        Option[] result; 
     
    236236                    string[] e; 
    237237                    for (uint k = 0; k < next.length-1; ++k) { 
    238                         finish_option(next[k], e); 
     238                        finishOption(next[k], e); 
    239239                    } 
    240240                    // For the last option, pass the unparsed tokens 
    241241                    // so that they can be added to next.back()'s values 
    242242                    // if appropriate. 
    243                     finish_option(next[$-1], m_args); 
     243                    finishOption(next[$-1], m_args); 
    244244                    for (uint j = 0; j < next.length; ++j) 
    245245                        result~=next[j]; 
     
    283283                //writefln("opt.position_key: ", opt.position_key); 
    284284                if (opt.position_key != -1) { 
    285                     if (position >= m_positional.max_total_count()) { 
     285                    if (position >= m_positional.maxTotalCount()) { 
    286286                        throw new TooManyPositionalOptionsError("too many positional options"); 
    287287                    } 
    288                     opt.string_key = m_positional.name_for_position(position); 
     288                    opt.string_key = m_positional.nameForPosition(position); 
    289289                    //writefln("Name for position ", position, "; ", m_positional.name_for_position(position)); 
    290290                    ++position; 
     
    296296            foreach(od; m_desc.options()) { 
    297297                if (od.is_selfdir) 
    298                     result~=new Option(od.long_name, [getDirName(self)]); 
     298                    result~=new Option(od.longName, [getDirName(self)]); 
    299299 
    300300                if (od.is_selfname) 
    301                     result~=new Option(od.long_name, [getBaseName(self)]); 
    302             } 
    303         } 
    304  
    305         return result; 
    306     } 
    307  
    308     Option[] parse_long_option(inout string[] args) { 
     301                    result~=new Option(od.longName, [getBaseName(self)]); 
     302            } 
     303        } 
     304 
     305        return result; 
     306    } 
     307 
     308    Option[] parseLongOption(inout string[] args) { 
    309309//        writefln("parse_long_option: args.length=", args.length); 
    310310        Option[] result; 
     
    336336 
    337337 
    338     Option[] parse_short_option(inout string[] args) { 
     338    Option[] parseShortOption(inout string[] args) { 
    339339//        writefln("parse_short_option: args.length=", args.length); 
    340340        Option[] result; 
     
    358358            for (;;) { 
    359359//                writefln("m_desc is null: ", m_desc is null); 
    360                 OptionDescription d = m_desc.find_nothrow(name, false); 
     360                OptionDescription d = m_desc.findNothrow(name, false); 
    361361//                writefln("parse_short_option::d=", d is null); 
    362362 
    363363                // FIXME: check for 'allow_sticky'. 
    364364                if (d !is null && (m_style & style_t.allow_sticky) && 
    365                         d.semantic().max_tokens() == 0 && !adjacent.length==0) { 
     365                        d.semantic.maxTokens() == 0 && !adjacent.length==0) { 
    366366                    // 'adjacent' is in fact further option. 
    367367//                    writefln("parse_short_option::   in 'if' condition"); 
     
    393393    } 
    394394 
    395     Option[] parse_dos_option(inout string[] args) { 
     395    Option[] parseDosOption(inout string[] args) { 
    396396//        writefln("parse_dos_option: args.length=", args.length); 
    397397        Option[] result; 
     
    411411    } 
    412412 
    413     Option[] parse_disguised_long_option(inout string[] args) { 
     413    Option[] parseDisguisedLongOption(inout string[] args) { 
    414414//        writefln("parse_disguised_long_option: args.length=", args.length); 
    415415        Option[] result; 
     
    417417        if (tok.length >= 2 && ((tok[0] == '-' && tok[1] != '-') || ((m_style & style_t.allow_slash_for_short) && tok[0] == '/'))) { 
    418418            bool aprox=(m_style & style_t.allow_guessing)==0 ? false : true; 
    419             if (m_desc.find_nothrow(tok[1..find(tok, '=')-1], aprox)) { 
     419            if (m_desc.findNothrow(tok[1..find(tok, '=')-1], aprox)) { 
    420420                args[0]="-"~args[0]; 
    421421                if (args[0][1] == '/') args[0][1] = '-'; 
    422                 return parse_long_option(args); 
    423             } 
    424         } 
    425         return result; 
    426     } 
    427  
    428     Option[] parse_terminator(inout string[] args) { 
     422                return parseLongOption(args); 
     423            } 
     424        } 
     425        return result; 
     426    } 
     427 
     428    Option[] parseTerminator(inout string[] args) { 
    429429//        writefln("parse_terminator: args.length=", args.length); 
    430430        Option[] result; 
     
    441441    } 
    442442 
    443     Option[] handle_additional_parser(inout string[] args) { 
     443    Option[] handleAdditionalParser(inout string[] args) { 
    444444//        writefln("handle_additional_parser: args.length=", args.length); 
    445445        Option[] result; 
     
    465465        Note that additional parser can match only one token. 
    466466    */ 
    467     void set_additional_parser(additional_parser p) { 
     467    void setAdditionalParser(additional_parser p) { 
    468468        m_additional_parser = p; 
    469469    } 
    470470 
    471     void extra_style_parser(style_parser s) { 
     471    void extraStyleParser(style_parser s) { 
    472472        m_style_parser = s; 
    473473    } 
    474474 
    475475 
    476     void check_style(int style) { 
     476    void checkStyle(int style) { 
    477477        bool allow_some_long = (style & style_t.allow_long) || (style & style_t.allow_long_disguise); 
    478478 
     
    493493    } 
    494494 
    495     void finish_option(Option opt, inout string[] other_tokens) { 
     495    void finishOption(Option opt, inout string[] other_tokens) { 
    496496        if (opt.string_key.length==0) return; 
    497497 
     
    500500        bool aprox=(m_style & style_t.allow_guessing)==0 ? false : true; 
    501501        //writefln("m_style & style_t.allow_guessing=", cast(int)(m_style & style_t.allow_guessing), " ", cast(int)m_style, " ", cast(int)(style_t.allow_guessing)); 
    502         OptionDescription xd = m_desc.find_nothrow(opt.string_key, aprox); 
     502        OptionDescription xd = m_desc.findNothrow(opt.string_key, aprox); 
    503503 
    504504        if (!xd) { 
     
    521521        // We don't check if those tokens look like option, or not! 
    522522 
    523         uint min_tokens = d.semantic().min_tokens()
    524         uint max_tokens = d.semantic().max_tokens()
     523        uint min_tokens = d.semantic.minTokens
     524        uint max_tokens = d.semantic.maxTokens
    525525 
    526526        uint present_tokens = opt.value.length + other_tokens.length; 
     
    589589    nuber of parameters will be confusing. 
    590590 
    591     For the most common case, the function parse_command_line is a better 
     591    For the most common case, the function parseCommandLine is a better 
    592592    alternative. 
    593593*/ 
     
    607607    /** Sets options descriptions to use. */ 
    608608    CommandLineParser options(OptionsDescription desc) { 
    609         set_options_description(desc); 
     609        setOptionsDescription(desc); 
    610610        m_desc = desc; 
    611611        return this; 
     
    614614    /** Sets positional options description to use. */ 
    615615    CommandLineParser positional(PositionalOptionsDescription desc) { 
    616         set_positional_options(desc); 
     616        setPositionalOptions(desc); 
    617617        return this; 
    618618    } 
     
    626626 
    627627    /** Sets the extra parsers. */ 
    628     CommandLineParser extra_parser(additional_parser ext) { 
    629         set_additional_parser(ext); 
     628    CommandLineParser extraParser(additional_parser ext) { 
     629        setAdditionalParser(ext); 
    630630        return this; 
    631631    } 
     
    647647 */ 
    648648 
    649 ParsedOptions parse_command_line(string[] args, OptionsDescription desc, int style = 0, additional_parser ext = null) { 
    650     return (new CommandLineParser(args)).options(desc).style(style).extra_parser(ext).run(); 
     649ParsedOptions parseCommandLine(string[] args, OptionsDescription desc, int style = 0, additional_parser ext = null) { 
     650    return (new CommandLineParser(args)).options(desc).style(style).extraParser(ext).run(); 
    651651} 
    652652 
  • trunk/doost/program_options/config_file_parser.d

    r5 r9  
    2121import doost.program_options.options_description; 
    2222 
     23//------------------------------------------------------------------------------ 
     24 
    2325/** Parse a config file. 
    2426*/ 
    25 ParsedOptions parse_config_file(string str, OptionsDescription desc) { 
     27ParsedOptions parseConfigFile(string str, OptionsDescription desc) { 
    2628    auto parser=new CommonConfigFileParser(desc); 
    27     return parser.parse_file(str); 
    28 } 
    29  
    30 ParsedOptions parse_config_file(string str, OptionsDescription desc, CommonConfigFileParser parser) { 
    31     return parser.parse_file(str); 
     29    return parser.parseFile(str); 
     30} 
     31 
     32ParsedOptions parseConfigFile(string str, OptionsDescription desc, CommonConfigFileParser parser) { 
     33    return parser.parseFile(str); 
    3234} 
    3335 
     
    3840 
    3941/* 
    40 ParsedOptions parse_config_file(std::istream& is) { 
     42ParsedOptions parseConfigFile(std::istream& is) { 
    4143    detail::config_file_iterator cf(is, false); 
    4244    ParsedOptions result(0); 
     
    8587        OptionDescription[] options = desc.options(); 
    8688        foreach(o; options) { 
    87             if (o.long_name().length==0) 
     89            if (o.longName.length==0) 
    8890                throw new InvalidConfigFileSyntax("", "long name required for config file"); 
    89             allowed_options[o.long_name()]=true; 
    90             add_option(o.long_name()); 
     91            allowed_options[o.longName()]=true; 
     92            addOption(o.longName()); 
    9193        } 
    9294    } 
     
    104106            // Handle section name 
    105107            if (s[0] == '[' && s[$-1] == ']') { 
    106                 m_prefix = s[1..$-2]; 
     108                m_prefix = s[1..$-1]; 
    107109                if (m_prefix[$-1] != '.') 
    108110                    m_prefix ~= '.'; 
     
    111113                string value = strip(s[n+1..$]); 
    112114 
    113                 if (!allowed_option(name)) 
     115                if (!allowedOption(name)) 
    114116                    throw new UnknownOption(name); 
    115117 
     
    128130    } 
    129131 
    130     ParsedOptions parse_file(string str) { 
     132    ParsedOptions parseFile(string str) { 
    131133        auto result = new ParsedOptions(m_desc); 
    132134        string[] lines=splitlines(str); 
     
    147149        'foo_bar' are allowed. */ 
    148150 
    149     void add_option(string name) { 
     151    void addOption(string name) { 
    150152        string s=name; 
    151153        assert(s.length!=0); 
     
    179181 
    180182    // Returns true if 's' is a registered option name. 
    181     bool allowed_option(string s) { 
     183    bool allowedOption(string s) { 
    182184        if (s in allowed_options) 
    183185            return true; 
  • trunk/doost/program_options/environment_parser.d

    r5 r9  
    7474    different from the naming of command line options. 
    7575*/ 
    76 ParsedOptions parse_environment(OptionsDescription desc, string delegate (string) name_mapper) { 
     76ParsedOptions parseEnvironment(OptionsDescription desc, string delegate (string) name_mapper) { 
    7777    auto result = new ParsedOptions(desc); 
    7878 
     
    101101    converting the remaining string into lower case. 
    102102*/ 
    103 ParsedOptions parse_environment(OptionsDescription desc, string prefix) { 
     103ParsedOptions parseEnvironment(OptionsDescription desc, string prefix) { 
    104104    auto p=new PrefixNameMapper(prefix); 
    105     return parse_environment(desc, &p.opCall); 
     105    return parseEnvironment(desc, &p.opCall); 
    106106} 
  • trunk/doost/program_options/errors.d

    r5 r9  
    9090        super(what); 
    9191    } 
    92     void set_option_name(string option_name) { 
     92    void setOptionName(string option_name) { 
    9393        m_option_name = option_name; 
    9494    } 
     
    151151 
    152152    this(string tokens, kind_t kind) { 
    153         super(tokens, error_message(kind)); 
     153        super(tokens, errorMessage(kind)); 
    154154        m_kind=kind; 
    155155    } 
     
    159159 
    160160protected: 
    161     static string error_message(kind_t kind) { 
     161    static string errorMessage(kind_t kind) { 
    162162        // Initially, store the message in 'const char*' variable, 
    163163        // to avoid conversion to std::string in all cases. 
  • trunk/doost/program_options/options_description.d

    r5 r9  
    3939*/ 
    4040 
    41 enum match_result { no_match, full_match, approximate_match }; 
     41enum MatchResult { no_match, full_match, approximate_match }; 
    4242 
    4343class OptionDescription { 
     
    5353        create objects of types derived from 'ValueSemantic': 
    5454           OptionsDescription d; 
    55            d.add_options()("a", parameter<int>("n")->default_value(1)); 
     55           d.addOptions()("a", parameter<int>("n")->default_value(1)); 
    5656        Here, the static type returned by 'parameter' should be derived 
    5757        from ValueSemantic. 
     
    7474    this(string name, ValueSemantic s) { 
    7575        m_value_semantic=s; 
    76         set_name(name); 
     76        setName(name); 
    7777    }; 
    7878 
     
    8484        m_description=description; 
    8585        m_value_semantic=s; 
    86         set_name(name); 
     86        setName(name); 
    8787    }; 
    8888 
    8989    /** Given 'option', specified in the input source, 
    9090        return 'true' is 'option' specifies *this. */ 
    91     match_result match(string option, bool approx) { 
    92         match_result result = match_result.no_match; 
     91    MatchResult match(string option, bool approx) { 
     92        MatchResult result = MatchResult.no_match; 
    9393        //writefln("m_long_name=", m_long_name, " approx=", approx, " option=", option); 
    9494        if (m_long_name!="") { 
     
    9797                // prefix is OK. 
    9898                if (find(option, m_long_name[0..$-2])==0) 
    99                     result=match_result.approximate_match; 
     99                    result=MatchResult.approximate_match; 
    100100            } 
    101101 
     
    103103                if (find(m_long_name, option) == 0) 
    104104                    if (m_long_name == option) 
    105                         result = match_result.full_match; 
     105                        result = MatchResult.full_match; 
    106106                    else 
    107                         result = match_result.approximate_match; 
     107                        result = MatchResult.approximate_match; 
    108108            } else { 
    109109                if (m_long_name == option) 
    110                     result = match_result.full_match; 
     110                    result = MatchResult.full_match; 
    111111            } 
    112112        } 
    113113 
    114114        if (m_short_name == option) 
    115             result = match_result.full_match; 
     115            result = MatchResult.full_match; 
    116116 
    117117        return result; 
     
    141141    } 
    142142 
    143     string long_name() { 
     143    string longName() { 
    144144        return m_long_name; 
    145145    } 
     
    156156 
    157157    /// Returns the option name, formatted suitably for usage message. 
    158     string format_name() { 
     158    string formatName() { 
    159159        if (m_short_name!="") return m_short_name~" [--"~m_long_name~"]"; 
    160160        else return "--"~m_long_name; 
     
    163163    /** Return the parameter name and properties, formatted suitably for 
    164164        usage message. */ 
    165     string format_parameter() { 
    166         if (m_value_semantic.max_tokens() != 0) return m_value_semantic.name()
     165    string formatParameter() { 
     166        if (m_value_semantic.maxTokens != 0) return m_value_semantic.name
    167167        else return ""; 
    168168    } 
     
    181181 
    182182private: 
    183     OptionDescription set_name(string _name) { 
     183    OptionDescription setName(string _name) { 
    184184        string name=_name; 
    185185        uint n = find(name, ','); 
     
    248248 
    249249/** A set of option descriptions. This provides convenient interface for 
    250     adding new option (the add_options) method, and facilities to search 
     250    adding new option (the addOptions) method, and facilities to search 
    251251    for options by name. 
    252252 
     
    302302        new OptionDescription instance and add it. 
    303303    */ 
    304     OptionsDescriptionEasyInit add_options() { 
     304    OptionsDescriptionEasyInit addOptions() { 
    305305        return new OptionsDescriptionEasyInit(this); 
    306306    } 
    307307 
    308308    OptionDescription find(string name, bool approx) { 
    309         OptionDescription d = find_nothrow(name, approx); 
     309        OptionDescription d = findNothrow(name, approx); 
    310310        if (d is null) throw new UnknownOption(name); 
    311311        return d; 
    312312    } 
    313313 
    314     OptionDescription find_nothrow(string name, bool approx) { 
     314    OptionDescription findNothrow(string name, bool approx) { 
    315315        int found = -1; 
    316316        // We use linear search because matching specified option 
     
    319319        for (uint i = 0; i < m_options.length; ++i) { 
    320320 
    321             match_result r = m_options[i].match(name, approx); 
    322  
    323             if (r == match_result.no_match) continue; 
     321            MatchResult r = m_options[i].match(name, approx); 
     322 
     323            if (r == MatchResult.no_match) continue; 
    324324 
    325325            // If we have a full match, and an approximate match, 
     
    332332            // two full matches. 
    333333 
    334             if (r == match_result.full_match) { 
     334            if (r == MatchResult.full_match) { 
    335335                return m_options[i]; 
    336336            } 
     
    373373            if (!opt.hidden) { 
    374374                string ss; 
    375                 ss = "  " ~ opt.format_name() ~ ' ' ~ opt.format_parameter(); 
     375                ss = "  " ~ opt.formatName() ~ ' ' ~ opt.formatParameter(); 
    376376                width = max!(uint)(width, ss.length); 
    377377            } 
     
    385385            if (belong_to_group[i] || m_options[i].hidden==true) continue; 
    386386            OptionDescription opt = m_options[i]; 
    387             result~=format_one(opt, width, m_line_length); 
     387            result~=formatOne(opt, width, m_line_length); 
    388388            result~='\n'; 
    389389        } 
     
    424424 
    425425 
    426 string format_paragraph(string par, uint indent, uint line_length) { 
     426string formatParagraph(string par, uint indent, uint line_length) { 
    427427    string result; 
    428428 
     
    522522//------------------------------------------------------------------------------ 
    523523 
    524 string format_description(string desc, uint first_column_width, uint line_length) { 
     524string formatDescription(string desc, uint first_column_width, uint line_length) { 
    525525    // we need to use one char less per line to work correctly if actual 
    526526    // console has longer lines 
     
    563563    string[] lines=splitlines(desc); 
    564564    foreach(line; lines) { 
    565         result~=format_paragraph(line, first_column_width, line_length); 
     565        result~=formatParagraph(line, first_column_width, line_length); 
    566566 
    567567        // prepair next line if any 
     
    578578//------------------------------------------------------------------------------ 
    579579 
    580 string format_one(OptionDescription opt, uint first_column_width, uint line_length) { 
    581     string result="  " ~ opt.format_name() ~ ' ' ~ opt.format_parameter(); 
     580string formatOne(OptionDescription opt, uint first_column_width, uint line_length) { 
     581    string result="  " ~ opt.formatName() ~ ' ' ~ opt.formatParameter(); 
    582582 
    583583    if (opt.description()!="") { 
     
    585585            result~=' '; 
    586586 
    587         result~=format_description(opt.description(), first_column_width, line_length); 
     587        result~=formatDescription(opt.description(), first_column_width, line_length); 
    588588    } 
    589589    return result; 
  • trunk/doost/program_options/positional_options.d

    r5 r9  
    5555        be present. Can return uint.max() to 
    5656        indicate unlimited number. */ 
    57     uint max_total_count() { 
     57    uint maxTotalCount() { 
    5858        return m_trailing=="" ? m_names.length : uint.max; 
    5959    } 
     
    6363        Precondition: position < max_total_count() 
    6464    */ 
    65     string name_for_position(uint position) { 
    66         assert(position < max_total_count()); 
     65    string nameForPosition(uint position) { 
     66        assert(position < maxTotalCount()); 
    6767 
    6868        if (position < m_names.length) return m_names[position]; 
  • trunk/doost/program_options/value_semantic.d

    r5 r9  
    3636    /** The minimum number of tokens for this option that 
    3737        should be present on the command line. */ 
    38     uint min_tokens(); 
     38    uint minTokens(); 
    3939 
    4040    /** The maximum number of tokens for this option that 
    4141        should be present on the command line. */ 
    42     uint max_tokens(); 
     42    uint maxTokens(); 
    4343 
    4444    /** Returns true if values from different sources should be composed. 
     
    4646        other sources are discarded. 
    4747    */ 
    48     bool is_composing(); 
     48    bool isComposing(); 
    4949 
    5050    /** Parses a group of tokens that specify a value of option. 
     
    5858        true if default value is assigned, and false if no default 
    5959        value exists. */ 
    60     bool apply_default(inout Any value_store); 
     60    bool applyDefault(inout Any value_store); 
    6161 
    6262    /** Called when final value of an option is determined. 
     
    7979    } 
    8080 
    81     override uint min_tokens() { 
     81    override uint minTokens() { 
    8282        if (m_zero_tokens) return 0; 
    8383        else return 1; 
    8484    } 
    8585 
    86     override uint max_tokens() { 
     86    override uint maxTokens() { 
    8787        if (m_zero_tokens) return 0; 
    8888        else return 1; 
    8989    } 
    9090 
    91     override bool is_composing() { 
     91    override bool isComposing() { 
    9292        return false; 
    9393    } 
     
    106106 
    107107    /** Does nothing. */ 
    108     override bool apply_default(inout Any b) { 
     108    override bool applyDefault(inout Any b) { 
    109109        return false; 
    110110    } 
     
    127127    // Returns the type of the value described by this 
    128128    // object. 
    129     TypeInfo value_type(); 
    130 }; 
     129    TypeInfo valueType(); 
     130} 
    131131 
    132132//------------------------------------------------------------------------------ 
     
    150150            provide operator<< for ostream. 
    151151        */ 
    152     TypedValue default_value(T v) { 
     152    TypedValue defaultValue(T v) { 
    153153        m_default_value.assign(v); 
    154154        //NOTE: more elegant: toString() - format needs when v = e.g. string[] 
     
    163163        by the user. 
    164164    */ 
    165     TypedValue default_value(T v, string textual) { 
     165    TypedValue defaultValue(T v, string textual) { 
    166166        m_default_value.assign(v); 
    167167        m_default_value_as_text = textual; 
     
    190190    } 
    191191 
    192     TypedValue zero_tokens() { 
     192    TypedValue zeroTokens() { 
    193193        m_zero_tokens = true; 
    194194        return this; 
     
    205205    } 
    206206 
    207     bool is_composing() { 
     207    bool isComposing() { 
    208208        return m_composing; 
    209209    } 
    210210 
    211     override uint min_tokens() { 
     211    override uint minTokens() { 
    212212        if (m_zero_tokens) return 0; 
    213213        else return 1; 
    214214    } 
    215215 
    216     override uint max_tokens() { 
     216    override uint maxTokens() { 
    217217        if (m_multitoken) { 
    218218            return 32000; 
     
    234234        Returns true if default value was stored. 
    235235    */ 
    236     override bool apply_default(inout Any value_store) { 
     236    override bool applyDefault(inout Any value_store) { 
    237237        if (m_default_value.empty()) return false; 
    238238        value_store.assign(m_default_value); 
     
    253253    } 
    254254 
    255     override TypeInfo value_type() { 
     255    override TypeInfo valueType() { 
    256256        return typeid(T); 
    257257    } 
     
    291291TypedValue!(bool) bool_switch(bool* v=null) { 
    292292    TypedValue!(bool) r = new TypedValue!(bool)(v); 
    293     r.default_value(0); 
    294     r.zero_tokens(); 
     293    r.defaultValue(0); 
     294    r.zeroTokens(); 
    295295    return r; 
    296296} 
     
    304304    otherwise. */ 
    305305 
    306 string get_single_string(string[] v, bool allow_empty = false) { 
     306string getSingleString(string[] v, bool allow_empty = false) { 
    307307    if (v.length > 1) throw new ValidationError("multiple values not allowed"); 
    308308    if (v.length == 1) return v[0]; 
     
    314314 
    315315/* Throws MultipleOccurrences if 'value' is not empty. */ 
    316 void check_first_occurrence(Any value) { 
     316void checkFirstOccurrence(Any value) { 
    317317    if (!value.empty()) 
    318318        throw new MultipleOccurrences("multiple_occurrences"); 
     
    329329*/ 
    330330void validate(T)(Any v, string[] xs) { 
    331     check_first_occurrence(v); 
    332     string s=get_single_string(xs); 
     331    checkFirstOccurrence(v); 
     332    string s=getSingleString(xs); 
    333333    try { 
    334334        //v = Any(lexical_cast<T>(s)); 
     
    377377*/ 
    378378void validate(T : bool)(Any v, string[] xs) { 
    379     check_first_occurrence(v); 
    380     string s=tolower(get_single_string(xs, true)); 
     379    checkFirstOccurrence(v); 
     380    string s=tolower(getSingleString(xs, true)); 
    381381 
    382382    if (s.length==0 || s == "on" || s == "yes" || s == "1" || s == "true") 
     
    391391 
    392392void validate(T : string)(Any v, string[] xs) { 
    393     check_first_occurrence(v); 
    394     string s=get_single_string(xs); 
     393    checkFirstOccurrence(v); 
     394    string s=getSingleString(xs); 
    395395    if ((s!="") && (s[0] == '\'' && s[$-1] == '\'' || s[0] == '"' && s[$-1] == '"')) 
    396396        v.assign(s[1..$-2]); 
  • trunk/doost/program_options/variables_map.d

    r5 r9  
    8181    } 
    8282 
    83     this(VariablesMap* next) { 
     83    this(VariablesMap next) { 
    8484        m_next=next; 
    8585    } 
     
    109109 
    110110 
    111         if (v.empty() && m_next) return (*m_next)[name]; 
     111        if (v.empty() && m_next) return m_next[name]; 
    112112        else if (v.defaulted() && m_next) { 
    113             VariableValue v2 = (*m_next)[name]; 
     113            VariableValue v2 = m_next[name]; 
    114114            if (!v2.empty() && !v2.defaulted()) return v2; 
    115115                else return v; 
     
    119119    /** Sets next variable map, which will be used to find 
    120120       variables not found in *this. */ 
    121     void next(VariablesMap* next) { 
     121    void next(VariablesMap next) { 
    122122        m_next = next; 
    123123    } 
    124124 
    125     // Moja funkcja - czy potrzebna? 
    126     VariableValue* opIn_r(string name) { 
    127         return (name in m_variables_map); 
     125    VariableValue opIn_r(string name) { 
     126        return opIndex(name); 
    128127    } 
    129128 
     
    141140    } 
    142141 
    143     VariablesMap* m_next; 
     142    VariablesMap m_next; 
    144143    VariableValue[string] m_variables_map; 
    145144 
     
    216215            d.semantic().parse(xm.m_variables_map[name].value(), options.options[i].value); 
    217216        } catch (ValidationError e) { 
    218             e.set_option_name(name); 
     217            e.setOptionName(name); 
    219218            throw e; 
    220219        } 
     
    226225        // so that several assignment inside *this* 'store' call 
    227226        // are allowed. 
    228         if (!d.semantic().is_composing()) new_final[name]=true; 
     227        if (!d.semantic.isComposing) new_final[name]=true; 
    229228    } 
    230229 
     
    242241        // internals. 
    243242        // The 'key' is empty if options description contains '*'. 
    244         // In that 
    245         // case, default value makes no sense at all. 
     243        // In that case, default value makes no sense at all. 
    246244        if (key.length==0) continue; 
    247245        if (!(key in xm.m_variables_map)) { 
    248246 
    249247            Any def=new Any; 
    250             if (d.semantic().apply_default(def)) { 
     248            if (d.semantic.applyDefault(def)) { 
    251249//                writefln("Istnieje defalut dla: ", key); 
    252250                xm.m_variables_map[key] = new VariableValue(def, true); 
  • trunk/examples/program_options/custom_syntax.d

    r8 r9  
    4343    try { 
    4444        auto desc = new OptionsDescription("Allowed options"); 
    45         desc.add_options() 
     45        desc.addOptions() 
    4646        ("help", "produce a help message") 
    4747        ("foo", value!(string)(), "just an option") 
     
    4949 
    5050        auto vm = new VariablesMap; 
    51         store((new CommandLineParser(args)).options(desc).extra_parser(delegate OptionPair (string s) { return reg_foo(s); }).run(), vm); 
     51        store((new CommandLineParser(args)).options(desc).extraParser(delegate OptionPair (string s) { return reg_foo(s); }).run(), vm); 
    5252 
    5353        if ("help" in vm) { 
  • trunk/examples/program_options/first.d

    r8 r9  
    2020 
    2121        auto desc = new OptionsDescription("Allowed options"); 
    22         desc.add_options() 
     22        desc.addOptions() 
    2323            ("help", "produce help message") 
    2424            ("compression", value!(int)(), "set compression level") 
     
    2626 
    2727        auto vm = new VariablesMap; 
    28         store(parse_command_line(args, desc), vm); 
     28        store(parseCommandLine(args, desc), vm); 
    2929        notify(vm); 
    3030 
  • trunk/examples/program_options/multiple_sources.d

    r8 r9  
    2626        // allowed only on command line 
    2727        auto generic = new OptionsDescription("Generic options"); 
    28         generic.add_options() 
     28        generic.addOptions() 
    2929        //Extension - special case when you declare selfdir and selfname in one 
    3030        //case 
     
    3838        // config file 
    3939        auto config = new OptionsDescription("Configuration"); 
    40         config.add_options() 
    41         ("optimization", value!(int)(&opt).default_value(10), "optimization level") 
     40        config.addOptions() 
     41        ("optimization", value!(int)(&opt).defaultValue(10), "optimization level") 
    4242        ("include-path,I", value!(string[])().composing(), "include path") 
    4343        ; 
     
    4646        // in config file, but will not be shown to the user. 
    4747        auto hidden=new OptionsDescription("Hidden options"); 
    48         hidden.add_options() 
     48        hidden.addOptions() 
    4949        ("input-file", value!(string[])(), "input file") 
    5050        ; 
     
    6969        // Parser