aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/small/last_getopt_parse_result.h
diff options
context:
space:
mode:
authoramatanhead <amatanhead@yandex-team.ru>2022-02-10 16:50:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:04 +0300
commitb6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/getopt/small/last_getopt_parse_result.h
parent8879605a63ac17539be5b3bd41b529791f4d4b02 (diff)
downloadydb-b6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9.tar.gz
Restoring authorship annotation for <amatanhead@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/getopt/small/last_getopt_parse_result.h')
-rw-r--r--library/cpp/getopt/small/last_getopt_parse_result.h288
1 files changed, 144 insertions, 144 deletions
diff --git a/library/cpp/getopt/small/last_getopt_parse_result.h b/library/cpp/getopt/small/last_getopt_parse_result.h
index a4baf8ca6b..1ab6f598c9 100644
--- a/library/cpp/getopt/small/last_getopt_parse_result.h
+++ b/library/cpp/getopt/small/last_getopt_parse_result.h
@@ -1,15 +1,15 @@
#pragma once
#include "last_getopt_opts.h"
-#include "last_getopt_parser.h"
+#include "last_getopt_parser.h"
namespace NLastGetopt {
/**
- * NLastGetopt::TOptParseResult contains all arguments for exactly one TOpt,
- * that have been fetched during parsing
- *
- * The class is a wraper over a vector of nil-terminated strings.
- */
+ * NLastGetopt::TOptParseResult contains all arguments for exactly one TOpt,
+ * that have been fetched during parsing
+ *
+ * The class is a wraper over a vector of nil-terminated strings.
+ */
class TOptParseResult {
public:
typedef TVector<const char*> TValues;
@@ -56,14 +56,14 @@ namespace NLastGetopt {
};
/**
- * NLastGetopt::TOptsParseResult contains result of parsing argc,argv be parser.
- *
- * In most common case constructed by argc,argv pair and rules (TOpts).
- * The instance being constructed validates rules and performs parsing, stores result for futher access.
- *
- * If error during parsing occures, the program aborts with exit code 1.
- * Note, that if PERMUTE mode is on, then data, pointed by argv can be changed.
- */
+ * NLastGetopt::TOptsParseResult contains result of parsing argc,argv be parser.
+ *
+ * In most common case constructed by argc,argv pair and rules (TOpts).
+ * The instance being constructed validates rules and performs parsing, stores result for futher access.
+ *
+ * If error during parsing occures, the program aborts with exit code 1.
+ * Note, that if PERMUTE mode is on, then data, pointed by argv can be changed.
+ */
class TOptsParseResult {
private:
THolder<TOptsParser> Parser_; //The instance of parser.
@@ -78,49 +78,49 @@ namespace NLastGetopt {
TOptParseResult& OptParseResult();
/**
- * Searchs for object in given container
- *
- * @param vec container
- * @param opt ptr for required object
- *
- * @retunr ptr on corresponding TOptParseResult
- */
+ * Searchs for object in given container
+ *
+ * @param vec container
+ * @param opt ptr for required object
+ *
+ * @retunr ptr on corresponding TOptParseResult
+ */
static const TOptParseResult* FindParseResult(const TdVec& vec, const TOpt* opt);
protected:
/**
- * Performs parsing of comand line arguments.
- */
+ * Performs parsing of comand line arguments.
+ */
void Init(const TOpts* options, int argc, const char** argv);
TOptsParseResult() = default;
public:
/**
- * The action in case of parser failure.
- * Allows to asjust behavior in derived classes.
- * By default prints error string and aborts the program
- */
+ * The action in case of parser failure.
+ * Allows to asjust behavior in derived classes.
+ * By default prints error string and aborts the program
+ */
virtual void HandleError() const;
/**
- * Constructs object by parsing arguments with given rules
- *
- * @param options ptr on parsing rules
- * @param argc
- * @param argv
- */
+ * Constructs object by parsing arguments with given rules
+ *
+ * @param options ptr on parsing rules
+ * @param argc
+ * @param argv
+ */
TOptsParseResult(const TOpts* options, int argc, const char* argv[]) {
Init(options, argc, argv);
}
/**
- * Constructs object by parsing arguments with given rules
- *
- * @param options ptr on parsing rules
- * @param argc
- * @param argv
- */
+ * Constructs object by parsing arguments with given rules
+ *
+ * @param options ptr on parsing rules
+ * @param argc
+ * @param argv
+ */
TOptsParseResult(const TOpts* options, int argc, char* argv[]) {
Init(options, argc, const_cast<const char**>(argv));
}
@@ -128,146 +128,146 @@ namespace NLastGetopt {
virtual ~TOptsParseResult() = default;
/**
- * Search for TOptParseResult that corresponds to given option (TOpt)
- *
- * @param opt ptr on required object
- * @param includeDefault search in results obtained from default values
- *
- * @return ptr on result
- */
+ * Search for TOptParseResult that corresponds to given option (TOpt)
+ *
+ * @param opt ptr on required object
+ * @param includeDefault search in results obtained from default values
+ *
+ * @return ptr on result
+ */
const TOptParseResult* FindOptParseResult(const TOpt* opt, bool includeDefault = false) const;
/**
- * Search for TOptParseResult that corresponds to given long name
- *
- * @param name long name of required object
- * @param includeDefault search in results obtained from default values
- *
- * @return ptr on result
- */
+ * Search for TOptParseResult that corresponds to given long name
+ *
+ * @param name long name of required object
+ * @param includeDefault search in results obtained from default values
+ *
+ * @return ptr on result
+ */
const TOptParseResult* FindLongOptParseResult(const TString& name, bool includeDefault = false) const;
/**
- * Search for TOptParseResult that corresponds to given short name
- *
- * @param c short name of required object
- * @param includeDefault search in results obtained from default values
- *
- * @return ptr on result
- */
+ * Search for TOptParseResult that corresponds to given short name
+ *
+ * @param c short name of required object
+ * @param includeDefault search in results obtained from default values
+ *
+ * @return ptr on result
+ */
const TOptParseResult* FindCharOptParseResult(char c, bool includeDefault = false) const;
/**
- * @return argv[0]
- */
+ * @return argv[0]
+ */
TString GetProgramName() const;
/**
- * Print usage string.
- */
- void PrintUsage(IOutputStream& os = Cout) const;
-
- /**
- * @return position in [premuted argv] of the first free argument
- */
+ * Print usage string.
+ */
+ void PrintUsage(IOutputStream& os = Cout) const;
+
+ /**
+ * @return position in [premuted argv] of the first free argument
+ */
size_t GetFreeArgsPos() const;
/**
- * @return number of fetched free arguments
- */
+ * @return number of fetched free arguments
+ */
size_t GetFreeArgCount() const;
/**
- * @return all fetched free arguments
- */
+ * @return all fetched free arguments
+ */
TVector<TString> GetFreeArgs() const;
/**
- * @return true if given option exist in results of parsing
- *
- * @param opt ptr on required object
- * @param includeDefault search in results obtained from default values
- *
- */
+ * @return true if given option exist in results of parsing
+ *
+ * @param opt ptr on required object
+ * @param includeDefault search in results obtained from default values
+ *
+ */
bool Has(const TOpt* opt, bool includeDefault = false) const;
/**
- * @return nil terminated string on the last fetched argument of givne option
- *
- * @param opt ptr on required object
- * @param includeDefault search in results obtained from default values
- */
+ * @return nil terminated string on the last fetched argument of givne option
+ *
+ * @param opt ptr on required object
+ * @param includeDefault search in results obtained from default values
+ */
const char* Get(const TOpt* opt, bool includeDefault = true) const;
/**
- * @return nil terminated string on the last fetched argument of givne option
- * if option haven't been fetched, given defaultValue will be returned
- *
- * @param opt ptr on required object
- * @param defaultValue
- */
+ * @return nil terminated string on the last fetched argument of givne option
+ * if option haven't been fetched, given defaultValue will be returned
+ *
+ * @param opt ptr on required object
+ * @param defaultValue
+ */
const char* GetOrElse(const TOpt* opt, const char* defaultValue) const;
/**
- * @return true if given option exist in results of parsing
- *
- * @param name long name of required object
- * @param includeDefault search in results obtained from default values
- *
- */
+ * @return true if given option exist in results of parsing
+ *
+ * @param name long name of required object
+ * @param includeDefault search in results obtained from default values
+ *
+ */
bool Has(const TString& name, bool includeDefault = false) const;
/**
- * @return nil terminated string on the last fetched argument of givne option
- *
- * @param name long name of required object
- * @param includeDefault search in results obtained from default values
- */
+ * @return nil terminated string on the last fetched argument of givne option
+ *
+ * @param name long name of required object
+ * @param includeDefault search in results obtained from default values
+ */
const char* Get(const TString& name, bool includeDefault = true) const;
/**
- * @return nil terminated string on the last fetched argument of givne option
- * if option haven't been fetched, given defaultValue will be returned
- *
- * @param name long name of required object
- * @param defaultValue
- */
+ * @return nil terminated string on the last fetched argument of givne option
+ * if option haven't been fetched, given defaultValue will be returned
+ *
+ * @param name long name of required object
+ * @param defaultValue
+ */
const char* GetOrElse(const TString& name, const char* defaultValue) const;
/**
- * @return true if given option exist in results of parsing
- *
- * @param c short name of required object
- * @param includeDefault search in results obtained from default values
- *
- */
+ * @return true if given option exist in results of parsing
+ *
+ * @param c short name of required object
+ * @param includeDefault search in results obtained from default values
+ *
+ */
bool Has(char name, bool includeDefault = false) const;
/**
- * @return nil terminated string on the last fetched argument of givne option
- *
- * @param c short name of required object
- * @param includeDefault search in results obtained from default values
- */
+ * @return nil terminated string on the last fetched argument of givne option
+ *
+ * @param c short name of required object
+ * @param includeDefault search in results obtained from default values
+ */
const char* Get(char name, bool includeDefault = true) const;
/**
- * @return nil terminated string on the last fetched argument of givne option
- * if option haven't been fetched, given defaultValue will be returned
- *
- * @param c short name of required object
- * @param defaultValue
- */
+ * @return nil terminated string on the last fetched argument of givne option
+ * if option haven't been fetched, given defaultValue will be returned
+ *
+ * @param c short name of required object
+ * @param defaultValue
+ */
const char* GetOrElse(char name, const char* defaultValue) const;
/**
- * for givne option return parsed value of the last fetched argument
- * if option haven't been fetched, HandleError action is called
- *
- * @param opt required option (one of: ptr, short name, long name).
- *
- * @return FromString<T>(last feteched argument)
- */
+ * for givne option return parsed value of the last fetched argument
+ * if option haven't been fetched, HandleError action is called
+ *
+ * @param opt required option (one of: ptr, short name, long name).
+ *
+ * @return FromString<T>(last feteched argument)
+ */
template <typename T, typename TKey>
T Get(const TKey opt) const {
const char* value = Get(opt);
@@ -280,14 +280,14 @@ namespace NLastGetopt {
}
/**
- * for givne option return parsed value of the last fetched argument
- * if option haven't been fetched, given defaultValue will be returned
- *
- * @param opt required option (one of: ptr, short name, long name).
- * @param defaultValue
- *
- * @return FromString<T>(last feteched argument)
- */
+ * for givne option return parsed value of the last fetched argument
+ * if option haven't been fetched, given defaultValue will be returned
+ *
+ * @param opt required option (one of: ptr, short name, long name).
+ * @param defaultValue
+ *
+ * @return FromString<T>(last feteched argument)
+ */
template <typename T, typename TKey>
T GetOrElse(const TKey opt, const T& defaultValue) const {
if (Has(opt))
@@ -298,11 +298,11 @@ namespace NLastGetopt {
};
/**
- * NLastGetopt::TOptsParseResultException contains result of parsing argc,argv be parser.
- *
- * Unlike TOptsParseResult, if error during parsing occures, an exception is thrown.
- *
- */
+ * NLastGetopt::TOptsParseResultException contains result of parsing argc,argv be parser.
+ *
+ * Unlike TOptsParseResult, if error during parsing occures, an exception is thrown.
+ *
+ */
class TOptsParseResultException: public TOptsParseResult {
public:
TOptsParseResultException(const TOpts* options, int argc, const char* argv[]) {