Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_VerbosityLevelCommandLineProcessorHelpers.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
12 #include "Teuchos_Array.hpp"
13 #include "Teuchos_Assert.hpp"
15 
16 
17 namespace {
18 
19 
20 using Teuchos::Array;
21 using Teuchos::tuple;
22 
23 
24 const Array<Teuchos::EVerbosityLevel>
25 verbosityLevelValues = tuple<Teuchos::EVerbosityLevel>(
32  );
33 
34 
35 const Array<std::string>
36 verbosityLevelNamesStorage = tuple<std::string>(
37  toString(Teuchos::VERB_DEFAULT),
38  toString(Teuchos::VERB_NONE),
39  toString(Teuchos::VERB_LOW),
40  toString(Teuchos::VERB_MEDIUM),
41  toString(Teuchos::VERB_HIGH),
43  );
44 
45 
46 Array<const char*> verbosityLevelNames;
47 // The above variable is Intialized below in order so that if exceptions are
48 // thrown then they will be caught in main()!
49 
50 
51 } // namespace
52 
53 
54 void Teuchos::setVerbosityLevelOption(
55  const std::string &optionName,
56  EVerbosityLevel *verbLevel,
57  const std::string &docString,
58  CommandLineProcessor *clp,
59  const bool required
60  )
61 {
62  const int numVerbLevels = implicit_cast<int>(verbosityLevelValues.size());
63 
64  if ( !verbosityLevelNames.size() ) {
65  verbosityLevelNames = tuple<const char*>(
66  verbosityLevelNamesStorage[0].c_str(),
67  verbosityLevelNamesStorage[1].c_str(),
68  verbosityLevelNamesStorage[2].c_str(),
69  verbosityLevelNamesStorage[3].c_str(),
70  verbosityLevelNamesStorage[4].c_str(),
71  verbosityLevelNamesStorage[5].c_str()
72  );
73  }
74 
75 #ifdef TEUCHOS_DEBUG
76  TEUCHOS_ASSERT( optionName.length() );
77  TEUCHOS_ASSERT( verbLevel );
78  TEUCHOS_ASSERT( clp );
79  TEUCHOS_ASSERT( implicit_cast<int>(verbosityLevelNamesStorage.size()) == numVerbLevels );
80  TEUCHOS_ASSERT( implicit_cast<int>(verbosityLevelNames.size()) == numVerbLevels );
81 #endif
82  clp->setOption(
83  optionName.c_str(), verbLevel,
84  numVerbLevels, &verbosityLevelValues[0], &verbosityLevelNames[0],
85  docString.c_str(), required
86  );
87 }
EVerbosityLevel
Verbosity level.
Generate a high level of output.
Generate only a minimal amount of output.
Generate the most output possible.
std::string toString(const any &rhs)
Converts the value in any to a std::string.
Generate no output.
TypeTo implicit_cast(const TypeFrom &t)
Perform an implicit cast of concrete types with the casted object returned by value.
Templated array class derived from the STL std::vector.
Basic command line parser for input from (argc,argv[])
Generate more output.
#define TEUCHOS_ASSERT(assertion_test)
This macro is throws when an assert fails.
Generate output as defined by the object.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...