#include <system_utils.hpp>
Public Types | |
typedef std::array< std::uint8_t, MachineIDSize > | MachineID |
Public Member Functions | |
MachineIDReader (const std::vector< std::string > &extra_search_locations={}) | |
MachineID | read () const |
std::pair< MachineID, std::string > | readAndGetLocation () const |
Static Public Member Functions | |
static std::vector< std::string > | getDefaultSearchLocations () |
Static Public Attributes | |
static constexpr int | MachineIDSize = 16 |
Private Member Functions | |
bool | tryRead (const std::string &location, MachineID &out_id) const |
Static Private Member Functions | |
static std::vector< std::string > | mergeLists (const std::vector< std::string > &a, const std::vector< std::string > &b) |
Private Attributes | |
const std::vector< std::string > | search_locations_ |
This class can find and read machine ID from a text file, represented as 32-char (16-byte) long hexadecimal string, possibly with separators (like dashes or colons). If the available ID is more than 16 bytes, extra bytes will be ignored. A shorter ID will not be accepted as valid. In order to be read, the ID must be located on the first line of the file and must not contain any whitespace characters.
Examples of valid ID: 0123456789abcdef0123456789abcdef 20CE0b1E-8C03-07C8-13EC-00242C491652
Definition at line 32 of file system_utils.hpp.
typedef std::array<std::uint8_t, MachineIDSize> uavcan_linux::MachineIDReader::MachineID |
Definition at line 37 of file system_utils.hpp.
|
inline |
This class can use extra seach locations. If provided, they will be checked first, before default ones.
Definition at line 108 of file system_utils.hpp.
|
inlinestatic |
Definition at line 39 of file system_utils.hpp.
|
inlinestaticprivate |
Definition at line 52 of file system_utils.hpp.
|
inline |
Just like readAndGetLocation(), but this one doesn't return location where this ID was obtained from.
Definition at line 115 of file system_utils.hpp.
|
inline |
This function checks available search locations and reads the ID from the first valid location. It returns std::pair<> with ID and the file path where it was read from. In case if none of the search locations turned out to be valid, uavcan_linux::Exception will be thrown.
Definition at line 122 of file system_utils.hpp.
|
inlineprivate |
Definition at line 61 of file system_utils.hpp.
|
staticconstexpr |
Definition at line 35 of file system_utils.hpp.
|
private |
Definition at line 50 of file system_utils.hpp.