1 // Created on: 2015-03-15
2 // Created by: Danila ULYANOV
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _ViewerTest_CmdParser_HeaderFile
17 #define _ViewerTest_CmdParser_HeaderFile
24 #include <Standard.hxx>
25 #include <Graphic3d_Vec.hxx>
29 class ViewerTest_CmdParser
33 //! Initializes default option.
34 ViewerTest_CmdParser();
36 //! Sets description for command.
37 void AddDescription (const std::string& theDescription)
39 myDescription = theDescription;
42 //! Adds option to available option list. Several names may be provided if separated with '|'.
43 void AddOption (const std::string& theOptionNames, const std::string& theOptionDescription = "");
45 //! Prints help message based on provided command and options descriptions.
48 //! Parses argument list; assignes local arguments to each option.
49 void Parse (Standard_Integer theArgsNb,
50 const char** theArgVec);
52 //! Checks if option was set with given minimal argument number.
53 //! Prints error message if isFatal flag was set.
54 Standard_Boolean HasOption (const std::string& theOptionName,
55 Standard_Integer theMandatoryArgsNb = 0,
56 Standard_Boolean isFatal = Standard_False);
58 //! Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'.
59 std::string Arg (const std::string& theOptionName, Standard_Integer theArgumentIndex);
61 // Interprets arguments of option 'theOptionName' as float vector starting with index 'theArgumentIndex'.
62 Graphic3d_Vec3 ArgVec3f (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
64 // Interprets arguments of option 'theOptionName' as double vector starting with index 'theArgumentIndex'.
65 Graphic3d_Vec3d ArgVec3d (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
67 // Interprets arguments of option 'theOptionName' as gp vector starting with index 'theArgumentIndex'.
68 gp_Vec ArgVec (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
70 // Interprets arguments of option 'theOptionName' as gp vector starting with index 'theArgumentIndex'.
71 gp_Pnt ArgPnt (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
73 // Interprets arguments of option 'theOptionName' as double at index 'theArgumentIndex'.
74 Standard_Real ArgDouble (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
76 // Interprets arguments of option 'theOptionName' as float at index 'theArgumentIndex'.
77 Standard_ShortReal ArgFloat (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
79 // Interprets arguments of option 'theOptionName' as integer at index 'theArgumentIndex'.
80 Standard_Integer ArgInt (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
82 // Interprets arguments of option 'theOptionName' as boolean at index 'theArgumentIndex'.
83 Standard_Boolean ArgBool (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
87 //! Object representing option state.
88 struct ViewerTest_CmdOption
90 ViewerTest_CmdOption() : IsSet (Standard_False) {}
93 std::string Description;
94 Standard_Boolean IsSet;
95 std::vector<std::string> Arguments;
98 //! Description of command.
99 std::string myDescription;
101 //! Map from all possible option names to option object indexes in myArgumentStorage.
102 std::map<std::string, Standard_Integer> myArgumentLists;
104 //! Container which stores option objects.
105 std::vector<ViewerTest_CmdOption> myArgumentStorage;
108 #endif // _ViewerTest_CmdParser_HeaderFile