⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 option.h

📁 epson usb2.0 控制芯片 S1R72V05 固件程序。
💻 H
字号:
/*
 *  TOPPERS/JSP Kernel
 *      Toyohashi Open Platform for Embedded Real-Time Systems/
 *      Just Standard Profile Kernel
 * 
 *  Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
 *                              Toyohashi Univ. of Technology, JAPAN
 * 
 *  忋婰挊嶌尃幰偼丆埲壓偺 (1)乣(4) 偺忦審偐丆Free Software Foundation 
 *  偵傛偭偰岞昞偝傟偰偄傞 GNU General Public License 偺 Version 2 偵婰
 *  弎偝傟偰偄傞忦審傪枮偨偡応崌偵尷傝丆杮僜僼僩僂僃傾乮杮僜僼僩僂僃傾
 *  傪夵曄偟偨傕偺傪娷傓丏埲壓摨偠乯傪巊梡丒暋惢丒夵曄丒嵞攝晍乮埲壓丆
 *  棙梡偲屇傇乯偡傞偙偲傪柍彏偱嫋戻偡傞丏
 *  (1) 杮僜僼僩僂僃傾傪僜乕僗僐乕僪偺宍偱棙梡偡傞応崌偵偼丆忋婰偺挊嶌
 *      尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕偑丆偦偺傑傑偺宍偱僜乕
 *      僗僐乕僪拞偵娷傑傟偰偄傞偙偲丏
 *  (2) 杮僜僼僩僂僃傾傪丆儔僀僽儔儕宍幃側偳丆懠偺僜僼僩僂僃傾奐敪偵巊
 *      梡偱偒傞宍偱嵞攝晍偡傞応崌偵偼丆嵞攝晍偵敽偆僪僉儏儊儞僩乮棙梡
 *      幰儅僯儏傾儖側偳乯偵丆忋婰偺挊嶌尃昞帵丆偙偺棙梡忦審偍傛傃壓婰
 *      偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
 *  (3) 杮僜僼僩僂僃傾傪丆婡婍偵慻傒崬傓側偳丆懠偺僜僼僩僂僃傾奐敪偵巊
 *      梡偱偒側偄宍偱嵞攝晍偡傞応崌偵偼丆師偺偄偢傟偐偺忦審傪枮偨偡偙
 *      偲丏
 *    (a) 嵞攝晍偵敽偆僪僉儏儊儞僩乮棙梡幰儅僯儏傾儖側偳乯偵丆忋婰偺挊
 *        嶌尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
 *    (b) 嵞攝晍偺宍懺傪丆暿偵掕傔傞曽朄偵傛偭偰丆TOPPERS僾儘僕僃僋僩偵
 *        曬崘偡傞偙偲丏
 *  (4) 杮僜僼僩僂僃傾偺棙梡偵傛傝捈愙揑傑偨偼娫愙揑偵惗偠傞偄偐側傞懝
 *      奞偐傜傕丆忋婰挊嶌尃幰偍傛傃TOPPERS僾儘僕僃僋僩傪柶愑偡傞偙偲丏
 * 
 *  杮僜僼僩僂僃傾偼丆柍曐徹偱採嫙偝傟偰偄傞傕偺偱偁傞丏忋婰挊嶌尃幰偍
 *  傛傃TOPPERS僾儘僕僃僋僩偼丆杮僜僼僩僂僃傾偵娭偟偰丆偦偺揔梡壜擻惈傕
 *  娷傔偰丆偄偐側傞曐徹傕峴傢側偄丏傑偨丆杮僜僼僩僂僃傾偺棙梡偵傛傝捈
 *  愙揑傑偨偼娫愙揑偵惗偠偨偄偐側傞懝奞偵娭偟偰傕丆偦偺愑擟傪晧傢側偄丏
 * 
 *  @(#) $Id: option.h,v 1.1 2006/04/14 02:46:06 9564907 Exp $
 */

// $Header: J:\\SapporoSoft\\usb20\\S1R72V05\\Debug\\Repository/S1R72V05_Toppers/Toppers/cfg/base/option.h,v 1.1 2006/04/14 02:46:06 9564907 Exp $

#ifndef OPTION_H
#define OPTION_H

#include "base/testsuite.h"
#include "base/singleton.h"

#include <string>
#include <vector>
#include <map>

#define DEFAULT_PARAMETER "#default"

using namespace std;

/*
 *   僆僾僔儑儞僷儔儊乕僞傪娗棟偡傞僋儔僗
 */
class OptionParameter
{
public:
    class OptionItem : public std::string
    {
    protected:
        bool                      checked;  //巊梡偟偨偐偳偆偐
        std::vector<std::string>  param;    //僆僾僔儑儞

    public:
            //僐儞僗僩儔僋僞
        OptionItem(void) throw() : string(DEFAULT_PARAMETER), checked(false) {}
        OptionItem(const std::string & name) throw() : string(name), checked(false) {}
        OptionItem(const OptionItem & src) throw() : string(src), checked(src.checked), param(src.param) {}

            //僆僾僔儑儞僷儔儊乕僞傪夝愅偟偰OptionItem傪惗惉偡傞
        static bool createItem(OptionItem & item, string & argv);

            //暿偺OptionItem偑帩偮僷儔儊乕僞傪帺暘偵捛壛偡傞
        void mergeItem(const OptionItem & src);

            //僷儔儊乕僞偺捛壛
        inline void addParameter(const std::string & src) throw()
        {   param.push_back(src);   }

            //僷儔儊乕僞悢偺庢摼
        inline size_t countParameter(void) const throw()
        {   return param.size();    }

            //僷儔儊乕僞傪帩偭偰偄傞偐偳偆偐
        inline bool hasParameter(void) const throw()
        {   return countParameter() != 0;   }

            //埵抲傪巜掕偟偰僷儔儊乕僞傪嶲徠 (柍岠側埵抲偩偲嬻暥帤)
        inline std::string operator[](std::vector<std::string>::size_type offset) const throw()
        {
            string result;

            if(offset < countParameter())
                result = param[offset];

            return result;
        }

            //偙偺僆僾僔儑儞傪巊梡偟偨偙偲傪婰偡 (OptionParameter傪夘偟偰偺棙梡偺傒側偺偱 "_" 傪偮偗偰偍偔)
        inline void _check(void) throw()
        {   checked = true;   }

            //偙偺僆僾僔儑儞偵怗偭偨偐偳偆偐
        inline bool isChecked(void) const throw()
        {   return checked;   }

            //桳岠偐偳偆偐 (側側偟偼柍岠)
        inline bool isValid(void) const throw()
        {   return !empty();   }

            //柍岠側僆僾僔儑儞傾僀僥儉偺惗惉
        static OptionItem createInvalidItem(void) throw();

            //慡偰偺僷儔儊乕僞寢崌偟偨傕偺傪庢摼
        std::string getParameters(std::string punctuator = " ") const throw();

            //僷儔儊乕僞偺屄悢傪僠僃僢僋
        bool checkParameterCount(size_t count, bool allow_zero = false) const throw();

        TESTSUITE_PROTOTYPE(main)
    };

protected:
        //僆僾僔儑儞傪奿擺偡傞曄悢
    std::map<std::string, OptionItem> container;    //set::begin()偼const_iterator偟偐曉偝側偄偺偱巇曽側偔map偵曄偊傞 (幚憰傪峫偊傟偽摉慠偐...)

        //僾儘僌儔儉柤徧
    std::string program_name;

        //僐儅儞僪儔僀儞偵搉偝傟偨堷悢偦偺傕偺
    std::string cmdline;    

        //僨僼僅儖僩僐儞僗僩儔僋僞 (僥僗僩梡)
    OptionParameter(void) throw() {}

        //梫慺偺専弌
    std::map<std::string, OptionItem>::iterator _find(const std::string & name, bool check = true) throw();

public:

        //僔儞僌儖僩儞僐儞僗僩儔僋僞
    SINGLETON_CONSTRUCTOR(OptionParameter) throw() {}

        //僆僾僔儑儞僷儔儊乕僞偺僷乕僗
    bool parseOption(int _argc, char const * const * _argv, char const * _default = NULL) throw();

        //慡偰偺僆僾僔儑儞偑巊梡偝傟偨偐偳偆偐偺妋擣
    bool validateOption(void) const throw();

        //巊梡偝傟側偐偭偨僆僾僔儑儞楍傪庢摼
    std::string getInvalidOptions(void) const throw();

        //傾僀僥儉偺悢傪悢偊傞
    inline size_t countItem(void) const throw()
    {   return container.size();   }

        //僆僾僔儑儞傾僀僥儉偺嶲徠
    OptionItem get(const std::string & name, bool check = true) throw();
    
    inline OptionItem operator [] (const std::string & name) throw()
    {   return get(name);   }
    
    inline OptionItem operator [] (const char * name) throw()
    {   return get(string(name));   }

        //僆僾僔儑儞偺桳柍偺専弌
    inline bool find(std::string name) throw()
    {   return get(name).isValid(); }


        //嶲徠儅乕僋傪偮偗傞
    inline bool check(const std::string & name) throw()
    {   return _find(name) != container.end();   }

    inline bool check(const char * name) throw()
    {   return check(string(name));   }

        //僾儘僌儔儉柤傪庢摼偡傞
    inline const std::string & getProgramName(void) const throw()
    {   return program_name;    }

        //堷悢楍傪偦偺傑傑庢摼偡傞 (僾儘僌儔儉柤偼娷傑偢)
    inline const std::string & getCommandLine(void) const throw()
    {   return cmdline;   }

    TESTSUITE_PROTOTYPE(main)
};

    /* 僔僗僥儉撪偱扨堦偺OptionParameter傪庢傞偨傔偺娭悢 */
inline OptionParameter & getOptionParameter(void) throw()
{   return *Singleton<OptionParameter>::getInstance();   }

#endif


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -