Libsockcanpp
A complete C++ wrapper around socketcan.
Loading...
Searching...
No Matches
Namespaces | Data Structures | Typedefs | Functions
sockcanpp Namespace Reference

Main library namespace. More...

Namespaces

namespace  exceptions
 

Data Structures

class  CanDriver
 CanDriver class; handles communication via CAN. More...
 
struct  CanId
 Represents a CAN ID in a simple and easy-to-use manner. More...
 
struct  CanIdHasher
 Implements a hash function for the CanId type. More...
 
class  CanMessage
 Represents a CAN message that was received. More...
 
class  EnumCheck
 
class  EnumCheck< EnumType >
 
class  EnumCheck< EnumType, V, Next... >
 

Typedefs

using filtermap_t = unordered_map< CanId, uint32_t, CanIdHasher >
 

Functions

template<typename... Args>
string formatString (const string &format, Args... args)
 Formats a std string object.
 

Detailed Description

Main library namespace.

This namespace contains the library's main code.

Typedef Documentation

◆ filtermap_t

using sockcanpp::filtermap_t = typedef unordered_map<CanId, uint32_t, CanIdHasher>

Definition at line 58 of file CanDriver.hpp.

Function Documentation

◆ formatString()

template<typename... Args>
string sockcanpp::formatString ( const string &  format,
Args...  args 
)

Formats a std string object.

Remarks
Yoinked from https://github.com/Beatsleigher/liblogpp :)
Template Parameters
ArgsThe formatting argument types.
Parameters
formatThe format string.
argsThe format arguments (strings must be converted to C-style strings!)
Returns
string The formatted string.

Definition at line 156 of file CanDriver.hpp.

156 {
157 using std::unique_ptr;
158 auto stringSize = snprintf(nullptr, 0, format.c_str(), args...) + 1; // +1 for \0
159 unique_ptr<char[]> buffer(new char[stringSize]);
160
161 snprintf(buffer.get(), stringSize, format.c_str(), args...);
162
163 return string(buffer.get(), buffer.get() + stringSize - 1); // std::string handles termination for us.
164 }

Referenced by sockcanpp::CanDriver::allowCanFdFrames(), sockcanpp::CanDriver::initialiseSocketCan(), sockcanpp::CanDriver::joinCanFilters(), sockcanpp::CanDriver::readMessageLock(), sockcanpp::CanDriver::readQueuedMessages(), sockcanpp::CanDriver::sendMessage(), sockcanpp::CanDriver::setCanFilters(), sockcanpp::CanDriver::setErrorFilter(), sockcanpp::CanDriver::setReceiveOwnMessages(), and sockcanpp::CanDriver::uninitialiseSocketCan().