MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / load

Function load

Tactility/Source/bluetooth/BluetoothPairedDevice.cpp:62–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62bool load(const std::string& addr_hex, PairedDevice& device) {
63 std::map<std::string, std::string> map;
64 if (!file::loadPropertiesFile(getFilePath(addr_hex), map)) return false;
65 if (!map.contains(KEY_ADDR)) return false;
66 if (!hexToAddr(map[KEY_ADDR], device.addr)) return false;
67
68 device.name = map.contains(KEY_NAME) ? map[KEY_NAME] : "";
69
70 device.autoConnect = !map.contains(KEY_AUTO_CONNECT) || (map[KEY_AUTO_CONNECT] == "true");
71
72 if (map.contains(KEY_PROFILE_ID)) {
73 // TODO: Handle incorrect parsing input
74 device.profileId = std::stoi(map[KEY_PROFILE_ID]);
75 }
76 return true;
77}
78
79bool save(const PairedDevice& device) {
80 const auto addr_hex = addrToHex(device.addr);

Callers 1

loadAllFunction · 0.70

Calls 3

loadPropertiesFileFunction · 0.85
getFilePathFunction · 0.85
hexToAddrFunction · 0.85

Tested by

no test coverage detected