0027818: Visualization - provide an interface to define highlight presentation properties
[occt.git] / src / ViewerTest / ViewerTest_CmdParser.hxx
CommitLineData
189f85a3 1// Created on: 2015-03-15
2// Created by: Danila ULYANOV
3// Copyright (c) 2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _ViewerTest_CmdParser_HeaderFile
17#define _ViewerTest_CmdParser_HeaderFile
18
19#include <map>
20#include <vector>
21#include <string>
22#include <algorithm>
23
24#include <Standard.hxx>
25#include <Graphic3d_Vec.hxx>
625e1958 26#include <gp_Vec.hxx>
189f85a3 27
28//! Command parser.
29class ViewerTest_CmdParser
30{
31public:
32
33 //! Initializes default option.
34 ViewerTest_CmdParser();
35
36 //! Sets description for command.
37 void AddDescription (const std::string& theDescription)
38 {
39 myDescription = theDescription;
40 }
41
42 //! Adds option to available option list. Several names may be provided if separated with '|'.
8e5fb5ea 43 void AddOption (const std::string& theOptionNames, const std::string& theOptionDescription = "");
189f85a3 44
45 //! Prints help message based on provided command and options descriptions.
46 void Help();
47
48 //! Parses argument list; assignes local arguments to each option.
49 void Parse (Standard_Integer theArgsNb,
50 const char** theArgVec);
51
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);
57
58 //! Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'.
59 std::string Arg (const std::string& theOptionName, Standard_Integer theArgumentIndex);
60
625e1958 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);
189f85a3 63
625e1958 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);
189f85a3 66
625e1958 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);
189f85a3 69
625e1958 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);
72
73 // Interprets arguments of option 'theOptionName' as double at index 'theArgumentIndex'.
74 Standard_Real ArgDouble (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
75
76 // Interprets arguments of option 'theOptionName' as float at index 'theArgumentIndex'.
77 Standard_ShortReal ArgFloat (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
78
79 // Interprets arguments of option 'theOptionName' as integer at index 'theArgumentIndex'.
80 Standard_Integer ArgInt (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
81
82 // Interprets arguments of option 'theOptionName' as boolean at index 'theArgumentIndex'.
83 Standard_Boolean ArgBool (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
189f85a3 84
85private:
86
87 //! Object representing option state.
88 struct ViewerTest_CmdOption
89 {
90 ViewerTest_CmdOption() : IsSet (Standard_False) {}
91
92 std::string Name;
93 std::string Description;
94 Standard_Boolean IsSet;
95 std::vector<std::string> Arguments;
96 };
97
98 //! Description of command.
99 std::string myDescription;
100
101 //! Map from all possible option names to option object indexes in myArgumentStorage.
102 std::map<std::string, Standard_Integer> myArgumentLists;
103
104 //! Container which stores option objects.
105 std::vector<ViewerTest_CmdOption> myArgumentStorage;
106};
107
108#endif // _ViewerTest_CmdParser_HeaderFile