25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

63 satır
1.7 KiB

  1. /******************************************************************************
  2. *
  3. * file: OptionalUnlabeledTracker.h
  4. *
  5. * Copyright (c) 2005, Michael E. Smoot .
  6. * All rights reverved.
  7. *
  8. * See the file COPYING in the top directory of this distribution for
  9. * more information.
  10. *
  11. * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
  12. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  14. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  16. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17. * DEALINGS IN THE SOFTWARE.
  18. *
  19. *****************************************************************************/
  20. #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H
  21. #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H
  22. #include <string>
  23. namespace TCLAP {
  24. class OptionalUnlabeledTracker
  25. {
  26. public:
  27. static void check( bool req, const std::string& argName );
  28. static void gotOptional() { alreadyOptionalRef() = true; }
  29. static bool& alreadyOptional() { return alreadyOptionalRef(); }
  30. private:
  31. static bool& alreadyOptionalRef() { static bool ct = false; return ct; }
  32. };
  33. inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName )
  34. {
  35. if ( OptionalUnlabeledTracker::alreadyOptional() )
  36. throw( SpecificationException(
  37. "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg",
  38. argName ) );
  39. if ( !req )
  40. OptionalUnlabeledTracker::gotOptional();
  41. }
  42. } // namespace TCLAP
  43. #endif