[#absl-CommandLineFlag] = xref:absl.adoc[absl]::CommandLineFlag :relfileprefix: ../ :mrdocs: A type‐erased handle for an instance of an Abseil Flag and holds reflection information pertaining to that flag. Use `CommandLineFlag` to access a flag's name, location, help string etc. == Synopsis Declared in `<absl/flags/commandlineflag.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CommandLineFlag; ---- == Description To obtain an `absl::CommandLineFlag`, invoke `absl::FindCommandLineFlag()` passing it the flag name string. Example: // Obtain reflection handle for a flag named "flagname". const absl::CommandLineFlag* my_flag_data = absl::FindCommandLineFlag("flagname"); // Now you can get flag info from that reflection handle. std::string flag_location = my_flag_data‐>Filename(); ... == Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/CommandLineFlag/2constructor-0b.adoc[`CommandLineFlag`] [.small]#[constructor]# | Constructors | xref:absl/CommandLineFlag/operator_assign.adoc[`operator=`] [.small]#[deleted]# | Not assignable. | xref:absl/CommandLineFlag/CurrentValue.adoc[`CurrentValue`] [.small]#[virtual]# | Returns the current value for this flag. | xref:absl/CommandLineFlag/DefaultValue.adoc[`DefaultValue`] [.small]#[virtual]# | Returns the default value for this flag. | xref:absl/CommandLineFlag/Filename.adoc[`Filename`] [.small]#[virtual]# | Returns name of the file where this flag is defined. | xref:absl/CommandLineFlag/Help.adoc[`Help`] [.small]#[virtual]# | Returns help message associated with this flag. | xref:absl/CommandLineFlag/IsOfType.adoc[`IsOfType`] | Returns true if the flag has type `T`. | xref:absl/CommandLineFlag/IsRetired.adoc[`IsRetired`] [.small]#[virtual]# | Returns true iff this object corresponds to retired flag. | xref:absl/CommandLineFlag/Name.adoc[`Name`] [.small]#[virtual]# | Returns name of this flag. | xref:absl/CommandLineFlag/ParseFrom.adoc[`ParseFrom`] | Sets the value of the flag based on specified string `value`. If the flag was successfully set to new value, it returns true. Otherwise, sets `error` to indicate the error, leaves the flag unchanged, and returns false. | xref:absl/CommandLineFlag/TryGet.adoc[`TryGet`] | Attempts to retrieve the flag value. |=== == Protected Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/CommandLineFlag/2destructor.adoc[`~CommandLineFlag`] [.small]#[destructor]# | Destroys this handle. Protected so only derived types may be destroyed. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/FindCommandLineFlag.adoc[`FindCommandLineFlag`] | Returns the reflection handle of an Abseil flag of the specified name, or `nullptr` if not found. This function will emit a warning if the name of a 'retired' flag is specified. | xref:absl/GetFlagReflectionHandle.adoc[`GetFlagReflectionHandle`] | Returns the reflection handle corresponding to specified Abseil Flag instance. Use this handle to access flag's reflection information, like name, location, default value etc. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#