cmdline.hpp

説明を見る。
00001 /*
00002  *  TOPPERS/FDMP Kernel
00003  *      Toyohashi Open Platform for Embedded Real-Time Systems/
00004  *      Function Distributed Multiprocessor Kernel
00005  *
00006  *  Copyright (C) 2004 by Witz Corporation, JAPAN    
00007  *  Copyright (C) 2005 by Takagi Nobuhisa
00008  * 
00009  *  上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation 
00010  *  によって公表されている GNU General Public License の Version 2 に記
00011  *  述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
00012  *  を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
00013  *  利用と呼ぶ)することを無償で許諾する.
00014  *  (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
00015  *      権表示,この利用条件および下記の無保証規定が,そのままの形でソー
00016  *      スコード中に含まれていること.
00017  *  (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
00018  *      用できる形で再配布する場合には,再配布に伴うドキュメント(利用
00019  *      者マニュアルなど)に,上記の著作権表示,この利用条件および下記
00020  *      の無保証規定を掲載すること.
00021  *  (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
00022  *      用できない形で再配布する場合には,次のいずれかの条件を満たすこ
00023  *      と.
00024  *    (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
00025  *        作権表示,この利用条件および下記の無保証規定を掲載すること.
00026  *    (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
00027  *        報告すること.
00028  *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
00029  *      害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
00030  * 
00031  *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
00032  *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
00033  *  含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
00034  *  接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
00035  * 
00036  */
00037 
00048 #ifndef TOPPERS_CMDLINE_HPP_
00049 #define TOPPERS_CMDLINE_HPP_
00050 
00051 #include "toppers/config.hpp"
00052 #include <memory>
00053 #include <string>
00054 #include <map>
00055 #include <set>
00056 #include <vector>
00057 #include <boost/shared_ptr.hpp>
00058 
00059 namespace toppers
00060 {
00061 
00066   class cmdline
00067   {
00068   public:
00073     class option_array
00074     {
00075     public:
00076       typedef std::multimap<std::string, std::string> map;
00077       typedef std::set<std::string> set;
00078 
00079       option_array();
00080       bool find( const std::string& key ) const;
00081       bool find( const std::string& key, std::string& arg ) const;
00082       bool find( const std::string& key, std::vector<std::string>& args ) const;
00083       void insert( const std::string& key, const std::string& value ); 
00084       bool replace( const std::string& key, const std::string& value );
00085       void remap_option( const std::string& old_key, const std::string& new_key );
00086       void swap( option_array& other ) throw();
00087     private:
00088       option_array( const map& options, const set& optset );
00089 
00090       map map_;
00091       set set_;   // 現在未使用
00092       friend class cmdline;
00093     };
00094 
00095     cmdline( int argc, char* argv[] );
00096     std::auto_ptr<std::vector<std::string> > parse( const std::string& pattern, option_array& options ) const;
00097     static std::vector<std::string>::const_iterator find_illegal_options( std::vector<std::string>::const_iterator first, std::vector<std::string>::const_iterator last );
00098   private:
00099     int argc_;
00100     char*const* argv_;
00101   };
00102 
00103 }
00104 
00105 #endif  // ! TOPPERS_CMDLINE_HPP_

Copyright © 2006 by TAKAGI Nobuhisa.
このページは Wed Apr 12 16:31:55 2006 に Doxygen によって生成されました。