| Flow 1.0.2
    Flow project: Full implementation reference. | 
#include "flow/util/detail/util_fwd.hpp"Go to the source code of this file.
| Namespaces | |
| namespace | flow | 
| Catch-all namespace for the Flow project: A collection of various production-quality modules written in modern C++17, originally by ygoldfel. | |
| namespace | flow::util | 
| Flow module containing miscellaneous general-use facilities that don't fit into any other Flow module. | |
| Macros | |
| #define | FLOW_UTIL_WHERE_AM_I_FROM_ARGS(ARG_file, ARG_function, ARG_line) ARG_file << ':' << ARG_function << '(' << ARG_line << ')' | 
| Helper macro, same as FLOW_UTIL_WHERE_AM_I(), but takes the source location details as arguments instead of grabbing them from __FILE__,__FUNCTION__,__LINE__.  More... | |
| #define | FLOW_UTIL_WHERE_AM_I_FROM_ARGS_TO_ARGS(ARG_file, ARG_function, ARG_line) ::flow::util::get_last_path_segment(ARG_file), ':', ARG_function, '(', ARG_line, ')' | 
| Helper macro, same as FLOW_UTIL_WHERE_AM_I_FROM_ARGS(), but results in a list of comma-separated, instead of <<separated, arguments, although they are still to be passed to anostreamwith exactly the same semantics as the aforementioned macro.  More... | |
| #define | FLOW_UTIL_WHERE_AM_I_LITERAL(ARG_function) FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_OUTER(ARG_function, __LINE__) | 
| Helper macro: like FLOW_UTIL_WHERE_AM_I(), with a major relative strength – its replacement is a string literal – and two differences: the function name must be supplied verbatim as an arg; and the source file name will contain the entire path as opposed to a massaged version with just the file-name component.  More... | |
| #define | FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_OUTER(ARG_function, ARG_line) FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_INNER(ARG_function, ARG_line) | 
| Impl helper macro from FLOW_UTIL_WHERE_AM_I_LITERAL().  More... | |
| #define | FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_INNER(ARG_function, ARG_line) __FILE__ ": " #ARG_function "(" #ARG_line ")" | 
| Impl helper macro from FLOW_UTIL_WHERE_AM_I_LITERAL().  More... | |
| Functions | |
| template<typename Rep , typename Period > | |
| Fine_duration | flow::util::chrono_duration_to_fine_duration (const boost::chrono::duration< Rep, Period > &dur) | 
| Helper that takes a non-negative duration of arbitrary precision/period and converts it to Fine_duration, rounding up.  More... | |
| template<typename Rep , typename Period > | |
| Fine_time_pt | flow::util::chrono_duration_from_now_to_fine_time_pt (const boost::chrono::duration< Rep, Period > &dur) | 
| Helper that takes a non-negative duration of arbitrary precision/period and converts it to Fine_duration, rounding up; then adds it to Fine_clock::now()and returns the result.  More... | |
| constexpr String_view | flow::util::get_last_path_segment (String_view path) | 
| Helper for FLOW_UTIL_WHERE_AM_I() that, given a pointer/length of a string in memory containing a path, returns a pointer/length into that same buffer that comprises the postfix just past the last directory separator or (if none exists) to all of it.  More... | |
| #define FLOW_UTIL_WHERE_AM_I_FROM_ARGS | ( | ARG_file, | |
| ARG_function, | |||
| ARG_line | |||
| ) | ARG_file << ':' << ARG_function << '(' << ARG_line << ')' | 
Helper macro, same as FLOW_UTIL_WHERE_AM_I(), but takes the source location details as arguments instead of grabbing them from __FILE__, __FUNCTION__, __LINE__. 
Arguably not useful outside of the flow::util module itself.
For best perf results: for all ARG_... that you pass in as flow::util::String_view please follow instructions in doc header of log::Msg_metadata::m_msg_src_file and log::Msg_metadata::m_msg_src_function.
| ARG_file | Full file name, as from __FILE__, as aString_view; or a fragment inside it (e.g., just the part past the last dir separator if any); depending on which part you'd prefer ultimately printed. | 
| ARG_function | Full function name, as from __FUNCTION__, as aString_view(recommended for perf) orconst char*. | 
| ARG_line | Line number, as from __LINE__. | 
ostream fragment X (suitable for, for example: std::cout << X << ": Hi!"). | #define FLOW_UTIL_WHERE_AM_I_FROM_ARGS_TO_ARGS | ( | ARG_file, | |
| ARG_function, | |||
| ARG_line | |||
| ) | ::flow::util::get_last_path_segment(ARG_file), ':', ARG_function, '(', ARG_line, ')' | 
Helper macro, same as FLOW_UTIL_WHERE_AM_I_FROM_ARGS(), but results in a list of comma-separated, instead of << separated, arguments, although they are still to be passed to an ostream with exactly the same semantics as the aforementioned macro. 
See doc header for FLOW_UTIL_WHERE_AM_I_FROM_ARGS().
| ARG_file | See FLOW_UTIL_WHERE_AM_I_FROM_ARGS(). | 
| ARG_function | See FLOW_UTIL_WHERE_AM_I_FROM_ARGS(). | 
| ARG_line | See FLOW_UTIL_WHERE_AM_I_FROM_ARGS(). | 
<<. | #define FLOW_UTIL_WHERE_AM_I_LITERAL | ( | ARG_function | ) | FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_OUTER(ARG_function, __LINE__) | 
Helper macro: like FLOW_UTIL_WHERE_AM_I(), with a major relative strength – its replacement is a string literal – and two differences: the function name must be supplied verbatim as an arg; and the source file name will contain the entire path as opposed to a massaged version with just the file-name component.
The key is that the function name arg is not to be a string: it is stringified to get the string.
Nevertheless, in perf-sensitive scenarios, this may well be worth it. For now we keep it in a detail/ header for use internally to Flow; we did in fact need this in flow::error.
Other than the aforementioned difference and mild formatting tweaks for cosmetics (as of this writing an added space), the format of the replacement's contents is identical to that from FLOW_UTIL_WHERE_AM_I().
Why need ARG_function? Why not simply use __FUNCTION__ internally? Answer: Despite its similar look to __FILE__, actually __FUNCTION__ is not a macro: it is an identifier (that refers to a const char*). The preprocessor knows what file (and line) it's scanning; but it has no idea what func it's scanning; that's only known at a later stage of compilation. So long story short: __FUNCTION__ is not replaced by a string literal and thus cannot be used to compose a string literal by compile-time concatenation.
(constexpr sweetness can be used for an otherwise compile-time-determined value; but we promised a literal here. constexprness is outside our scope. Though perhaps see FLOW_UTIL_WHERE_AM_I_FROM_ARGS() for that.)
| ARG_function | Informally this is something akin to ARG_functionto FLOW_ERROR_EXEC_AND_THROW_ON_ERROR(). Formally this can be anything; it will be stringified via#ARG_functionand output as the function name. (Do not attempt to pass here the name of a string-typed variable; that probably won't do what you want. E.g., if you invokeFLOW_UTIL_WHERE_AM_I_LITERAL(func_name), andfunc_nameis anstd::stringwith a function name, then the macro replacement will be"/some/file.cpp:func_name(332)"– withoutfunc_namegetting replaced by the contents of yourfunc_namevariable or whatever.) | 
__FILE__), function name given, and line number (from __LINE__). The string literal will be in the form "stuff" "more stuff" "more stuff" (etc.). There will be no surrounding parentheses (in case you want to compile-time-concatenate to even more literal segments). | #define FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_INNER | ( | ARG_function, | |
| ARG_line | |||
| ) | __FILE__ ": " #ARG_function "(" #ARG_line ")" | 
Impl helper macro from FLOW_UTIL_WHERE_AM_I_LITERAL().
This is the real impl; see also FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_OUTER().
| ARG_function | See FLOW_UTIL_WHERE_AM_I_LITERAL(). | 
| ARG_line | The line number integer as from __LINE__. | 
| #define FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_OUTER | ( | ARG_function, | |
| ARG_line | |||
| ) | FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_INNER(ARG_function, ARG_line) | 
Impl helper macro from FLOW_UTIL_WHERE_AM_I_LITERAL().
This intermediate between that guy and the "true" impl macro FLOW_UTIL_WHERE_AM_I_LITERAL_IMPL_INNER() is needed in order for the preprocessor to substitute __LINE__ instead of simply stringifying it as "__LINE__".
| ARG_function | See FLOW_UTIL_WHERE_AM_I_LITERAL(). | 
| ARG_line | Literally __LINE__. |