OmniSciDB  c07336695a
CommandHistoryFileImpl< ENV_RESOLVER > Class Template Reference

#include <CommandHistoryFile.h>

+ Inheritance diagram for CommandHistoryFileImpl< ENV_RESOLVER >:
+ Collaboration diagram for CommandHistoryFileImpl< ENV_RESOLVER >:

Public Member Functions

 CommandHistoryFileImpl ()
 
 CommandHistoryFileImpl (std::string command_file_name)
 
 operator char const * () const
 

Private Member Functions

auto resolveHomeDirectory () const
 
std::string const resolveCommandFile () const
 

Private Attributes

std::string command_file_name_
 

Friends

template<typename ER >
std::istream & operator>> (std::istream &i, CommandHistoryFileImpl< ER > &cmd_file)
 
template<typename ER >
std::ostream & operator<< (std::ostream &o, CommandHistoryFileImpl< ER > const &cmd_file)
 

Detailed Description

template<typename ENV_RESOLVER>
class CommandHistoryFileImpl< ENV_RESOLVER >

Definition at line 49 of file CommandHistoryFile.h.

Constructor & Destructor Documentation

◆ CommandHistoryFileImpl() [1/2]

template<typename ENV_RESOLVER>
CommandHistoryFileImpl< ENV_RESOLVER >::CommandHistoryFileImpl ( )
inline

Definition at line 51 of file CommandHistoryFile.h.

◆ CommandHistoryFileImpl() [2/2]

template<typename ENV_RESOLVER>
CommandHistoryFileImpl< ENV_RESOLVER >::CommandHistoryFileImpl ( std::string  command_file_name)
inlineexplicit

Definition at line 52 of file CommandHistoryFile.h.

53  : command_file_name_(command_file_name) {}

Member Function Documentation

◆ operator char const *()

template<typename ENV_RESOLVER>
CommandHistoryFileImpl< ENV_RESOLVER >::operator char const * ( ) const
inline

Definition at line 55 of file CommandHistoryFile.h.

References operator<<(), and operator>>().

55 { return command_file_name_.c_str(); }
+ Here is the call graph for this function:

◆ resolveCommandFile()

template<typename ENV_RESOLVER>
std::string const CommandHistoryFileImpl< ENV_RESOLVER >::resolveCommandFile ( ) const
inlineprivate

Definition at line 76 of file CommandHistoryFile.h.

References getDefaultHistoryFilename().

76  {
77  auto* home_dir = resolveHomeDirectory();
78  if (home_dir == nullptr) { // Just use default command history file name in current
79  // dir in this scenario
80  return std::string(getDefaultHistoryFilename());
81  }
82  return std::string(home_dir) + '/' + getDefaultHistoryFilename();
83  }
constexpr char const *const getDefaultHistoryFilename()
auto resolveHomeDirectory() const
+ Here is the call graph for this function:

◆ resolveHomeDirectory()

template<typename ENV_RESOLVER>
auto CommandHistoryFileImpl< ENV_RESOLVER >::resolveHomeDirectory ( ) const
inlineprivate

Definition at line 65 of file CommandHistoryFile.h.

References DefaultEnvResolver::getenv().

65  {
66  auto* home_env = this->getenv("HOME");
67  if (home_env == nullptr) {
68  auto* passwd_entry = ENV_RESOLVER::getpwuid(ENV_RESOLVER::getuid());
69  if (passwd_entry != nullptr) {
70  home_env = passwd_entry->pw_dir;
71  }
72  }
73  return home_env;
74  }
+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

template<typename ENV_RESOLVER>
template<typename ER >
std::ostream& operator<< ( std::ostream &  o,
CommandHistoryFileImpl< ER > const &  cmd_file 
)
friend

◆ operator>>

template<typename ENV_RESOLVER>
template<typename ER >
std::istream& operator>> ( std::istream &  i,
CommandHistoryFileImpl< ER > &  cmd_file 
)
friend

Member Data Documentation

◆ command_file_name_

template<typename ENV_RESOLVER>
std::string CommandHistoryFileImpl< ENV_RESOLVER >::command_file_name_
private

Definition at line 86 of file CommandHistoryFile.h.

Referenced by operator<<(), and operator>>().


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