mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
mx Namespace Reference

The mxlib c++ namespace. More...

The mxlib c++ namespace.

Namespaces

namespace  internal
 Namespace for the internal error reporting functions.
 
namespace  verbose
 Namespace for the error reporting verbosity levels.
 

Classes

class  exception
 Augments an exception with the source file and line. More...
 

Enumerations

enum class  error_t {
  error_t::noerror , error_t::error , error_t::invalidarg , error_t::invalidconfig ,
  error_t::notimpl , error_t::paramnotset , error_t::envnotset , error_t::notfound ,
  error_t::sizeerr , error_t::allocerr , error_t::freeerr , error_t::parseerr ,
  error_t::filesystem , error_t::fileoerr , error_t::filewerr , error_t::filererr ,
  error_t::filecerr , error_t::filenotfound , error_t::fileempty , error_t::dirnotfound ,
  error_t::dirempty , error_t::procerr , error_t::timeout , error_t::liberr ,
  error_t::exception , error_t::std_exception , error_t::std_bad_alloc , error_t::std_logic_error ,
  error_t::std_invalid_argument , error_t::std_domain_error , error_t::std_length_error , error_t::std_out_of_range ,
  error_t::std_future_error , error_t::std_bad_optional_access , error_t::std_filesystem_error , error_t::std_runtime_error ,
  error_t::std_range_error , error_t::std_overflow_error , error_t::std_underflow_error , error_t::std_ios_base_failure ,
  error_t::std_format_error , error_t::gnuploterr , error_t::lapackerr , error_t::e2big ,
  error_t::eacces , error_t::eaddrinuse , error_t::eaddrnotavail , error_t::eafnosupport ,
  error_t::eagain , error_t::ealready , error_t::ebadf , error_t::ebadmsg ,
  error_t::ebusy , error_t::ecanceled , error_t::echild , error_t::econnaborted ,
  error_t::econnrefused , error_t::econnreset , error_t::edestaddrreq , error_t::edom ,
  error_t::eexist , error_t::efault , error_t::efbig , error_t::ehostunreach ,
  error_t::eidrm , error_t::eilseq , error_t::einprogress , error_t::eintr ,
  error_t::einval , error_t::eio , error_t::eisconn , error_t::eisdir ,
  error_t::eloop , error_t::emfile , error_t::emlink , error_t::emsgsize ,
  error_t::enametoolong , error_t::enetdown , error_t::enetreset , error_t::enetunreach ,
  error_t::enfile , error_t::enobufs , error_t::enodata , error_t::enodev ,
  error_t::enoent , error_t::enoexec , error_t::enolck , error_t::enolink ,
  error_t::enomem , error_t::enomsg , error_t::enoprotoopt , error_t::enospc ,
  error_t::enosr , error_t::enostr , error_t::enosys , error_t::enotconn ,
  error_t::enotdir , error_t::enotempty , error_t::enotrecoverable , error_t::enotsock ,
  error_t::enotsup , error_t::enotty , error_t::enxio , error_t::eopnotsupp ,
  error_t::eoverflow , error_t::eownerdead , error_t::eperm , error_t::epipe ,
  error_t::eproto , error_t::eprotonosupport , error_t::eprototype , error_t::erange ,
  error_t::erofs , error_t::espipe , error_t::esrch , error_t::etime ,
  error_t::etimedout , error_t::etxtbsy , error_t::ewouldblock , error_t::exdev ,
  error_t::fits_same_file , error_t::fits_too_many_files , error_t::fits_file_not_opened , error_t::fits_file_not_created ,
  error_t::fits_write_error , error_t::fits_end_of_file , error_t::fits_read_error , error_t::fits_file_not_closed ,
  error_t::fits_array_too_big , error_t::fits_readonly_file , error_t::fits_memory_allocation , error_t::fits_bad_fileptr ,
  error_t::fits_null_input_ptr , error_t::fits_seek_error , error_t::fits_bad_nettimeout , error_t::fits_bad_url_prefix ,
  error_t::fits_too_many_drivers , error_t::fits_driver_init_failed , error_t::fits_no_matching_driver , error_t::fits_url_parse_error ,
  error_t::fits_range_parse_error , error_t::fits_shared_badarg , error_t::fits_shared_nulptr , error_t::fits_shared_tabfull ,
  error_t::fits_shared_notinit , error_t::fits_shared_ipcerr , error_t::fits_shared_nomem , error_t::fits_shared_again ,
  error_t::fits_shared_nofile , error_t::fits_shared_noresize , error_t::fits_header_not_empty , error_t::fits_key_no_exist ,
  error_t::fits_key_out_bounds , error_t::fits_value_undefined , error_t::fits_no_quote , error_t::fits_bad_index_key ,
  error_t::fits_bad_keychar , error_t::fits_bad_order , error_t::fits_not_pos_int , error_t::fits_no_end ,
  error_t::fits_bad_bitpix , error_t::fits_bad_naxis , error_t::fits_bad_naxes , error_t::fits_bad_pcount ,
  error_t::fits_bad_gcount , error_t::fits_bad_tfields , error_t::fits_neg_width , error_t::fits_neg_rows ,
  error_t::fits_col_not_found , error_t::fits_bad_simple , error_t::fits_no_simple , error_t::fits_no_bitpix ,
  error_t::fits_no_naxis , error_t::fits_no_naxes , error_t::fits_no_xtension , error_t::fits_not_atable ,
  error_t::fits_not_btable , error_t::fits_no_pcount , error_t::fits_no_gcount , error_t::fits_no_tfields ,
  error_t::fits_no_tbcol , error_t::fits_no_tform , error_t::fits_not_image , error_t::fits_bad_tbcol ,
  error_t::fits_not_table , error_t::fits_col_too_wide , error_t::fits_col_not_unique , error_t::fits_bad_row_width ,
  error_t::fits_unknown_ext , error_t::fits_unknown_rec , error_t::fits_end_junk , error_t::fits_bad_header_fill ,
  error_t::fits_bad_data_fill , error_t::fits_bad_tform , error_t::fits_bad_tform_dtype , error_t::fits_bad_tdim ,
  error_t::fits_bad_heap_ptr , error_t::fits_bad_hdu_num , error_t::fits_bad_col_num , error_t::fits_neg_file_pos ,
  error_t::fits_neg_bytes , error_t::fits_bad_row_num , error_t::fits_bad_elem_num , error_t::fits_not_ascii_col ,
  error_t::fits_not_logical_col , error_t::fits_bad_atable_format , error_t::fits_bad_btable_format , error_t::fits_no_null ,
  error_t::fits_not_vari_len , error_t::fits_bad_dimen , error_t::fits_bad_pix_num , error_t::fits_zero_scale ,
  error_t::fits_neg_axis , error_t::fits_not_group_table , error_t::fits_hdu_already_member , error_t::fits_member_not_found ,
  error_t::fits_group_not_found , error_t::fits_bad_group_id , error_t::fits_too_many_hdus_tracked , error_t::fits_hdu_already_tracked ,
  error_t::fits_bad_option , error_t::fits_identical_pointers , error_t::fits_bad_group_attach , error_t::fits_bad_group_detach ,
  error_t::fits_ngp_no_memory , error_t::fits_ngp_read_err , error_t::fits_ngp_nul_ptr , error_t::fits_ngp_empty_curline ,
  error_t::fits_ngp_unread_queue_full , error_t::fits_ngp_inc_nesting , error_t::fits_ngp_err_fopen , error_t::fits_ngp_eof ,
  error_t::fits_ngp_bad_arg , error_t::fits_ngp_token_not_expect , error_t::fits_bad_i2c , error_t::fits_bad_f2c ,
  error_t::fits_bad_intkey , error_t::fits_bad_logicalkey , error_t::fits_bad_floatkey , error_t::fits_bad_doublekey ,
  error_t::fits_bad_c2i , error_t::fits_bad_c2f , error_t::fits_bad_c2d , error_t::fits_bad_datatype ,
  error_t::fits_bad_decim , error_t::fits_num_overflow , error_t::fits_data_compression_err , error_t::fits_data_decompression_err ,
  error_t::fits_bad_date , error_t::fits_parse_syntax_err , error_t::fits_parse_bad_type , error_t::fits_parse_lrg_vector ,
  error_t::fits_parse_no_output , error_t::fits_parse_bad_col , error_t::fits_parse_bad_output , error_t::fits_angle_too_big ,
  error_t::fits_bad_wcs_val , error_t::fits_wcs_error , error_t::fits_bad_wcs_proj , error_t::fits_no_wcs_key ,
  error_t::fits_approx_wcs_key , error_t::cuda_success , error_t::cuda_invalid_value , error_t::cuda_memory_allocation ,
  error_t::cuda_initialization_error , error_t::cuda_cudart_unloading , error_t::cuda_profiler_disabled , error_t::cuda_profiler_not_initialized ,
  error_t::cuda_profiler_already_started , error_t::cuda_profiler_already_stopped , error_t::cuda_invalid_configuration , error_t::cuda_invalid_pitch_value ,
  error_t::cuda_invalid_symbol , error_t::cuda_invalid_host_pointer , error_t::cuda_invalid_device_pointer , error_t::cuda_invalid_texture ,
  error_t::cuda_invalid_texture_binding , error_t::cuda_invalid_channel_descriptor , error_t::cuda_invalid_memcpy_direction , error_t::cuda_address_of_constant ,
  error_t::cuda_texture_fetch_failed , error_t::cuda_texture_not_bound , error_t::cuda_synchronization_error , error_t::cuda_invalid_filter_setting ,
  error_t::cuda_invalid_norm_setting , error_t::cuda_mixed_device_execution , error_t::cuda_not_yet_implemented , error_t::cuda_memory_value_too_large ,
  error_t::cuda_stub_library , error_t::cuda_insufficient_driver , error_t::cuda_call_requires_newer_driver , error_t::cuda_invalid_surface ,
  error_t::cuda_duplicate_variable_name , error_t::cuda_duplicate_texture_name , error_t::cuda_duplicate_surface_name , error_t::cuda_devices_unavailable ,
  error_t::cuda_incompatible_driver_context , error_t::cuda_missing_configuration , error_t::cuda_prior_launch_failure , error_t::cuda_launch_max_depth_exceeded ,
  error_t::cuda_launch_file_scoped_tex , error_t::cuda_launch_file_scoped_surf , error_t::cuda_sync_depth_exceeded , error_t::cuda_launch_pending_count_exceeded ,
  error_t::cuda_invalid_device_function , error_t::cuda_no_device , error_t::cuda_invalid_device , error_t::cuda_device_not_licensed ,
  error_t::cuda_software_validity_not_established , error_t::cuda_startup_failure , error_t::cuda_invalid_kernel_image , error_t::cuda_device_uninitialized ,
  error_t::cuda_map_buffer_object_failed , error_t::cuda_unmap_buffer_object_failed , error_t::cuda_array_is_mapped , error_t::cuda_already_mapped ,
  error_t::cuda_no_kernel_image_for_device , error_t::cuda_already_acquired , error_t::cuda_not_mapped , error_t::cuda_not_mapped_as_array ,
  error_t::cuda_not_mapped_as_pointer , error_t::cuda_e_c_c_uncorrectable , error_t::cuda_unsupported_limit , error_t::cuda_device_already_in_use ,
  error_t::cuda_peer_access_unsupported , error_t::cuda_invalid_ptx , error_t::cuda_invalid_graphics_context , error_t::cuda_nvlink_uncorrectable ,
  error_t::cuda_jit_compiler_not_found , error_t::cuda_unsupported_ptx_version , error_t::cuda_jit_compilation_disabled , error_t::cuda_unsupported_exec_affinity ,
  error_t::cuda_invalid_source , error_t::cuda_file_not_found , error_t::cuda_shared_object_symbol_not_found , error_t::cuda_shared_object_init_failed ,
  error_t::cuda_operating_system , error_t::cuda_invalid_resource_handle , error_t::cuda_illegal_state , error_t::cuda_symbol_not_found ,
  error_t::cuda_not_ready , error_t::cuda_illegal_address , error_t::cuda_launch_out_of_resources , error_t::cuda_launch_timeout ,
  error_t::cuda_launch_incompatible_texturing , error_t::cuda_peer_access_already_enabled , error_t::cuda_peer_access_not_enabled , error_t::cuda_set_on_active_process ,
  error_t::cuda_context_is_destroyed , error_t::cuda_assert , error_t::cuda_too_many_peers , error_t::cuda_host_memory_already_registered ,
  error_t::cuda_host_memory_not_registered , error_t::cuda_hardware_stack_error , error_t::cuda_illegal_instruction , error_t::cuda_misaligned_address ,
  error_t::cuda_invalid_address_space , error_t::cuda_invalid_pc , error_t::cuda_launch_failure , error_t::cuda_cooperative_launch_too_large ,
  error_t::cuda_not_permitted , error_t::cuda_not_supported , error_t::cuda_system_not_ready , error_t::cuda_system_driver_mismatch ,
  error_t::cuda_compat_not_supported_on_device , error_t::cuda_mps_connection_failed , error_t::cuda_mps_rpc_failure , error_t::cuda_mps_server_not_ready ,
  error_t::cuda_mps_max_clients_reached , error_t::cuda_mps_max_connections_reached , error_t::cuda_mps_client_terminated , error_t::cuda_cdp_not_supported ,
  error_t::cuda_cdp_version_mismatch , error_t::cuda_stream_capture_unsupported , error_t::cuda_stream_capture_invalidated , error_t::cuda_stream_capture_merge ,
  error_t::cuda_stream_capture_unmatched , error_t::cuda_stream_capture_unjoined , error_t::cuda_stream_capture_isolation , error_t::cuda_stream_capture_implicit ,
  error_t::cuda_captured_event , error_t::cuda_stream_capture_wrong_thread , error_t::cuda_timeout , error_t::cuda_graph_exec_update_failure ,
  error_t::cuda_external_device , error_t::cuda_invalid_cluster_size , error_t::cuda_unknown , error_t::cuda_api_failure_base ,
  error_t::__sentinel
}
 The mxlib error codes. More...
 

Functions

template<typename iosT , char comment = '#'>
iosT & dumpGitStatus (iosT &ios, const std::string &repoName, const std::string &branch, const std::string &sha1, const bool &modified, const std::string &section="")
 Dump the git status of a repository to a stream.
 
template<typename iosT , char comment = '#'>
iosT & dumpGitStatus (iosT &ios)
 Dump the current git status of the mxlib library to a stream.
 
bool operator! (const error_t &errc)
 Check if an error_t code is an error.
 
bool operator== (const error_t &errc, bool tf)
 Check if an error_t code is an error.
 
bool operator!= (const error_t &errc, bool tf)
 Check if an error_t code is not an error.
 
bool isError (const error_t &errc)
 Check if an error_t code is an error.
 
template<class verboseT = verbose::d>
std::string error_message (const error_t &code, const std::string &expl, const std::source_location &loc=std::source_location::current())
 Format a report given an mxlib error_t code and explanation.
 
template<>
std::string error_message< mx::verbose::o > (const error_t &code, const std::string &expl, const std::source_location &loc)
 Specialization of error_message for verbose::o.
 
template<>
std::string error_message< mx::verbose::v > (const error_t &code, const std::string &expl, const std::source_location &loc)
 Specialization of error_message for verbose::v.
 
template<>
std::string error_message< mx::verbose::vv > (const error_t &code, const std::string &expl, const std::source_location &loc)
 Specialization of error_message for verbose::vv.
 
template<>
std::string error_message< mx::verbose::vvv > (const error_t &code, const std::string &expl, const std::source_location &loc)
 Specialization of error_message for verbose::vvv.
 
template<class verboseT = verbose::vvv>
std::string error_message (const error_t &code, const std::source_location &loc=std::source_location::current())
 Format a report given an mxlib error_t code.
 
template<>
std::string error_message< mx::verbose::o > (const error_t &code, const std::source_location &loc)
 Specialization of error_message for verbose::o.
 
template<>
std::string error_message< mx::verbose::v > (const error_t &code, const std::source_location &loc)
 Specialization of error_message for verbose::v.
 
template<>
std::string error_message< mx::verbose::vv > (const error_t &code, const std::source_location &loc)
 Specialization of error_message for verbose::vv.
 
template<>
std::string error_message< mx::verbose::vvv > (const error_t &code, const std::source_location &loc)
 Specialization of error_message for verbose::vvv.
 
template<class verboseT = verbose::vvv>
error_t error_report (const error_t &code, const std::string &expl, const std::source_location &loc=std::source_location::current())
 Print a report to stderr given an mxlib error_t code and explanation and return the code.
 
template<>
error_t error_report< mx::verbose::o > (const error_t &code, const std::string &expl, const std::source_location &loc)
 Specialization of error_report for verbose::o.
 
template<class verboseT = verbose::vvv>
error_t error_report (const error_t &code, const std::source_location &loc=std::source_location::current())
 Print a report to stderr given an mxlib error_t code and return the code.
 
template<>
error_t error_report< mx::verbose::o > (const error_t &code, const std::source_location &loc)
 Specialization of error_report for verbose::o.
 
static constexpr const char * errorName (const error_t &errc)
 Convert a error_t code to its name.
 
static constexpr const char * errorMessage (const error_t &errc)
 Get the descriptive message for a error_t code.
 
static constexpr error_t errno2error_t (const int &err)
 Convert an errno code to error_t.
 
static constexpr error_t fits_status2error_t (const int &err)
 Convert a FITS status code to error_t.
 
void unwind_exceptions (std::vector< std::string > &whats, const std::exception &e)
 Extract the explanatory string of nested exceptions, placing them in a vector.
 
void print_exceptions (std::vector< std::string > &whats, const std::string &message="exception(s) thrown")
 Print nested exceptions to stderr, from the earliest to latest.
 
std::string MXE_CodeToName (int ec)
 Return the name for an mxlib error code.
 
std::string MXE_CodeToDescription (int ec)
 Return the description for an mxlib error code.
 
std::string errno_CodeToName (int ec)
 Return the macro name and a message for a standard errno code.
 
std::string error_report (const std::string &source, const int &code, const std::string &file, const int &line, const std::string &expl="")
 Construct a rich error report given an mxlib error code.
 
std::string errno_report (const std::string &source, int ec, const std::string &file, const int &line, const std::string &expl="")
 Construct a rich error report given a standard errno error code.
 

Function Documentation

◆ dumpGitStatus() [1/2]

template<typename iosT , char comment = '#'>
iosT & mx::dumpGitStatus ( iosT &  ios)

Dump the current git status of the mxlib library to a stream.

Prints the current SHA1 hash and whether or not the library has been modified since that commit.

Template Parameters
iosTa std::ostream-like type
commenta character to print at the beginning of each line. Default is '#'.
Parameters
[in]iosa std::ostream-like stream.

Definition at line 90 of file mxlib.hpp.

References dumpGitStatus().

◆ dumpGitStatus() [2/2]

template<typename iosT , char comment = '#'>
iosT & mx::dumpGitStatus ( iosT &  ios,
const std::string &  repoName,
const std::string &  branch,
const std::string &  sha1,
const bool &  modified,
const std::string &  section = "" 
)

Dump the git status of a repository to a stream.

Prints the provided SHA1 hash and whether or not the library has been modified since that commit.

Template Parameters
iosTa std::ostream-like type
commenta character to print at the beginning of each line. Default is '#'.
Parameters
[in]iosa std::ostream-like stream.
[in]repoNameThe name of the repository
[in]branchThe name of the branch
[in]sha1The sha1 hash for the current commit
[in]modifiedWhether or not the repository is currently modified
[in]section[optional] Descriptive sub-section name (e.g. headers vs. compiled)

Definition at line 53 of file mxlib.hpp.

Referenced by mx::AO::analysis::aoSystem< _realT, _inputSpectT, iosT >::dumpAOSystem(), and dumpGitStatus().

◆ print_exceptions()

void mx::print_exceptions ( std::vector< std::string > &  whats,
const std::string &  message = "exception(s) thrown" 
)
inline

Print nested exceptions to stderr, from the earliest to latest.

Formats in a ladder

Parameters
[out]whatsa vector of what messages
[in]message[optional] the top message to print

Definition at line 174 of file exception.hpp.

◆ unwind_exceptions()

void mx::unwind_exceptions ( std::vector< std::string > &  whats,
const std::exception &  e 
)
inline

Extract the explanatory string of nested exceptions, placing them in a vector.

If the exception is nested, this recurses to extract the explanatory string of the next exception it holds.

Parameters
[out]whatsthe vector of what messages
[in]ethe exception

Definition at line 150 of file exception.hpp.

References unwind_exceptions().

Referenced by unwind_exceptions().