00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021  
00022 
00023 
00024 #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H
00025 #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H
00026 
00027 #include <string>
00028 
00029 namespace TCLAP {
00030 
00031 class OptionalUnlabeledTracker
00032 {
00033 
00034     public:
00035 
00036         static void check( bool req, const std::string& argName );
00037 
00038         static void gotOptional() { alreadyOptionalRef() = true; }
00039 
00040         static bool& alreadyOptional() { return alreadyOptionalRef(); } 
00041 
00042     private:
00043 
00044         static bool& alreadyOptionalRef() { static bool ct = false; return ct; }
00045 };
00046 
00047 
00048 inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName )
00049 {
00050     if ( OptionalUnlabeledTracker::alreadyOptional() )
00051         throw( SpecificationException(
00052     "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg",
00053                     argName ) );
00054 
00055     if ( !req )
00056         OptionalUnlabeledTracker::gotOptional();
00057 }
00058 
00059 
00060 } 
00061 
00062 #endif