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 46 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 561 of file kernel.cpp.

562{
563 std::cerr << "ERROR [" << msg << "]:\n"; return std::cerr;
564}

◆ error_msg() [2/2]

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

Definition at line 52 of file defs.hpp.

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

◆ real_path()

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

Definition at line 599 of file kernel.cpp.

600{
601 char resolved_name[PATH_MAX];
602
603 if(realpath(path.c_str(), resolved_name) != 0) {
604 path = resolved_name;
605 return true;
606 }
607 else {
608 if(ignore_errors) {
609 TLOG_DEBUG( 3) << "realpath(\'" << path << "\') has failed with code " << errno << ": \'" << strerror(errno) << '\'' ;
610 return false;
611 }
612 else {
613 throw CannotResolvePath(path, errno);
614 }
615 }
616}
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
const std::string strerror(int error)
Convert C error number to string.
Definition kernel.cpp:119

◆ substitute_variables()

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

Definition at line 575 of file kernel.cpp.

576{
577 std::string::size_type pos = 0; // position of tested string index
578 std::string::size_type p_start = 0; // begining of variable
579 std::string::size_type p_end = 0; // begining of variable
580
581 while(
582 ((p_start = s.find("$(", pos)) != std::string::npos) &&
583 ((p_end = s.find(")", p_start + 2)) != std::string::npos)
584 ) {
585 std::string var(s, p_start + 2, p_end - p_start - 2);
586
587 char * env = getenv(var.c_str());
588
589 if(env) {
590 s.replace(p_start, p_end - p_start + 1, env);
591 }
592
593 pos = p_start + 1;
594 }
595}

◆ warning_msg() [1/2]

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

Definition at line 568 of file kernel.cpp.

569{
570 std::cerr << "WARNING [" << msg << "]:\n"; return std::cerr;
571}

◆ warning_msg() [2/2]

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

Definition at line 53 of file defs.hpp.

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

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