ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
samplecamp.hpp
Go to the documentation of this file.
1// #################################################################################################
2// ALib C++ Framework
3// Configuration Sample
4//
5// Copyright 2025 A-Worx GmbH, Germany
6// Published under Boost Software License (a free software license, see LICENSE.txt)
7// #################################################################################################
8/// \file
9#include "ALib.Lang.H"
10
11// Include necessary ALib Camp headers
12#include "ALib.Camp.Base.H" // Include customized module bootstrapping
13#include "ALib.CLI.H" // Include ALib CLI module
14
15#if !DOXYGEN // otherwise this sample would be seen in the ALib dox
16
17DOX_MARKER( [DOX_EXPR_TUT_CLI_ENUMS])
18enum class Commands {
19 Now = 1, ///< Returns the current date.
20 File = 2, ///< returns the modification date of a file or directory.
21 Help = 99, ///< Prints a help text.
22};
23
24enum class Options {
25 Format = 0, ///< Overwrite the default format string.
26 Help = 99, ///< Show help text. (We allow this as option as well a command)
27};
28
29enum class Parameters {
30 Filename = 0, ///< Used with command \e file to denote the file.
31 Topic = 1, ///< Used with command \e help to optionally denote a help topic.
32};
33
34enum class ExitCodes {
35 OK = 0, ///< Success.
36 ErrUnknownCommand = 100, ///< Unknown command given.
37 ErrUnknownOption = 101, ///< Unknown option given.
38 ErrMissingFilename = 102, ///< Command "file" given without a filename.
39 ErrUnknownHelpTopic = 103, ///< Command or option "help" given without an unknown subtopic.
40 ErrInternalError = 255, ///< Unspecified internal error.
41 /// (this demo might be incomplete :-)
42};
43DOX_MARKER( [DOX_EXPR_TUT_CLI_ENUMS])
44
45DOX_MARKER( [DOX_EXPR_TUT_CLI_ENUMS_ASSIGN])
46// assigning ALib enum records
51DOX_MARKER( [DOX_EXPR_TUT_CLI_ENUMS_ASSIGN])
52
53DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_DECL])
54class SampleCamp : public alib::camp::Camp {
55 public:
56 // Constructor. Passes version number and resource name to the module class
57 SampleCamp() : Camp("DATEMOD") {}
58
59 protected:
60 // Initialization of the module.
61 virtual void Bootstrap() override;
62
63 // Terminate this module. (Nothing to do.)
64 virtual void Shutdown( alib::ShutdownPhases phase ) override;
65}; // class SampleCamp
66DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_DECL])
67
68DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_SINGLETON])
69// The module singleton object
70extern SampleCamp SAMPLE_CAMP;
71DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_SINGLETON])
72
73DOX_MARKER( [DOX_EXPR_TUT_CLI_ENUMS_ASSIGN2])
74// Specifying our custom module to hold resources of our enum records
75ALIB_RESOURCED_IN_CAMP( Commands , SAMPLE_CAMP, "Commands" )
76ALIB_RESOURCED_IN_CAMP( Parameters, SAMPLE_CAMP, "Parameters" )
77ALIB_RESOURCED_IN_CAMP( Options , SAMPLE_CAMP, "Options" )
78ALIB_RESOURCED_IN_CAMP( ExitCodes , SAMPLE_CAMP, "ExitCodes" )
79DOX_MARKER( [DOX_EXPR_TUT_CLI_ENUMS_ASSIGN2])
80
81#endif // !DOXYGEN
#define ALIB_RESOURCED_IN_CAMP(T, Camp, ResName)
virtual void Bootstrap()=0
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
Options
Built-in options used with class #"AppCli".
ExitCodes
Built-in exit-code used with class #"AppCli".
@ ErrUnknownCommand
Unknown command.
Commands
Built-in commands used with class #"AppCli".
@ Help
Show help text.
Parameters
Built-in parameters of commands and options used with class #"AppCli".
@ Topic
Used with command help to optionally denote a help topic.
@ Filename
Denotes the actual source file as the scope.
files::File File
Type alias in namespace alib.
Definition ftree.inl:1055
ShutdownPhases
Termination levels usable with #"alib_mod_bs_camps;Bootstrapping ALib Camps".
Definition camp.inl:42
void Shutdown()
#"alib_enums_records;ALib Enum Record" type used by class #"CommandDecl".
#"alib_enums_records;ALib Enum Record" type used by class #"OptionDecl".
#"alib_enums_records;ALib Enum Record" type used by class #"ParameterDecl".
Definition arguments.inl:52