advgetopt/option_info_ref.cpp
/** \brief Retrieve the referenced option as a long.
 *
 * This function attempts to retrieve the option value as a long integer.
 *
 * If the value is not yet defined, the function attempts to return the
 * default value converted to an integer. If that fails, the function
 * returns -1 after it emitted an error in the log.
 *
 * When the value is not defined and there is no default, the function
 * returns 0 (as if an empty string represented 0.)
 *
 * \return The value as a long or -1.
 */
\brief Retrieve the referenced option as a long.
This function attempts to retrieve the option value as a long integer.

If the value is not yet defined, the function attempts to return the
default value converted to an integer. If that fails, the function
returns -1 after it emitted an error in the log.

When the value is not defined and there is no default, the function
returns 0 (as if an empty string represented 0.)

\return The value as a long or -1.
\ brief Retrieve the referenced option as a long . This function attempts to retrieve the option value as a long integer . If the value is not yet defined the function attempts to return the default value converted to an integer . If that fails the function returns - 1 after it emitted an error in the log . When the value is not defined and there is no default the function returns 0 ( as if an empty string represented 0 . ) \ return The value as a long or - 1 .
long option_info_ref::get_long() const
{
    if(f_opt->is_defined())
    {
        return f_opt->get_long();
    }
    if(!f_opt->has_default())
    {
        return 0;
    }
    std::int64_t v;
    if(!validator_integer::convert_string(f_opt->get_default(), v))
    {
        cppthread::log << cppthread::log_level_t::error
                       << "invalid default value for a number ("
                       << f_opt->get_default()
                       << ") in parameter --"
                       << f_opt->get_name()
                       << " at offset 0."
                       << cppthread::end;
        return -1;
    }
    return v;
}
long option_info_ref :: get_long ( ) const { if ( f_opt -> is_defined ( ) ) { return f_opt -> get_long ( ) ; } if ( ! f_opt -> has_default ( ) ) { return 0 ; } std :: int64_t v ; if ( ! validator_integer :: convert_string ( f_opt -> get_default ( ) , v ) ) { cppthread :: log << cppthread :: log_level_t :: error << " " << f_opt -> get_default ( ) << " " << f_opt -> get_name ( ) << " " << cppthread :: end ; return -1 ; } return v ; }
\brief Retrieve the referenced option as a long.
\ brief Retrieve the referenced option as a long .