DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::Oks Class Reference

Class contains common OKS classes and methods. More...

#include <defs.hpp>

Classes

class  Tokenizer
 String tokenizer. More...

Static Public Member Functions

static std::ostream & error_msg (const char *)
static std::ostream & warning_msg (const char *)
static std::ostream & error_msg (const std::string &s)
static std::ostream & warning_msg (const std::string &s)
static void substitute_variables (std::string &)
static bool real_path (std::string &, bool ignore_errors)

Detailed Description

Class contains common OKS classes and methods.

Definition at line 42 of file defs.hpp.

Member Function Documentation

◆ error_msg() [1/2]

std::ostream & dunedaq::oks::Oks::error_msg ( const char * msg)
static

Definition at line 511 of file kernel.cpp.

512{
513 std::cerr << "ERROR [" << msg << "]:\n";
514 return std::cerr;
515}

◆ error_msg() [2/2]

std::ostream & dunedaq::oks::Oks::error_msg ( const std::string & s)
inlinestatic

Definition at line 48 of file defs.hpp.

48{ return error_msg(s.c_str()); }
static std::ostream & error_msg(const char *)
Definition kernel.cpp:511

◆ real_path()

bool dunedaq::oks::Oks::real_path ( std::string & path,
bool ignore_errors )
static

Definition at line 546 of file kernel.cpp.

547{
548 char resolved_name[PATH_MAX];
549
550 if (realpath(path.c_str(), resolved_name) != 0) {
551 path = resolved_name;
552 return true;
553 } else {
554 if (ignore_errors) {
555 TLOG_DEBUG(3) << "realpath(\'" << path << "\') has failed with code " << errno << ": \'" << strerror(errno)
556 << '\'';
557 return false;
558 } else {
559 throw CannotResolvePath(path, errno);
560 }
561 }
562}
CannotResolvePath(const std::string &path, int error_code) noexcept
Definition kernel.hpp:378
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
const std::string strerror(int error)
Convert C error number to string.
Definition kernel.cpp:111

◆ substitute_variables()

void dunedaq::oks::Oks::substitute_variables ( std::string & s)
static

Definition at line 525 of file kernel.cpp.

526{
527 std::string::size_type pos = 0; // position of tested string index
528 std::string::size_type p_start = 0; // begining of variable
529 std::string::size_type p_end = 0; // begining of variable
530
531 while (((p_start = s.find("$(", pos)) != std::string::npos) &&
532 ((p_end = s.find(")", p_start + 2)) != std::string::npos)) {
533 std::string var(s, p_start + 2, p_end - p_start - 2);
534
535 char* env = getenv(var.c_str());
536
537 if (env) {
538 s.replace(p_start, p_end - p_start + 1, env);
539 }
540
541 pos = p_start + 1;
542 }
543}

◆ warning_msg() [1/2]

std::ostream & dunedaq::oks::Oks::warning_msg ( const char * msg)
static

Definition at line 518 of file kernel.cpp.

519{
520 std::cerr << "WARNING [" << msg << "]:\n";
521 return std::cerr;
522}

◆ warning_msg() [2/2]

std::ostream & dunedaq::oks::Oks::warning_msg ( const std::string & s)
inlinestatic

Definition at line 49 of file defs.hpp.

49{ return warning_msg(s.c_str()); }
static std::ostream & warning_msg(const char *)
Definition kernel.cpp:518

The documentation for this class was generated from the following files: