/** * Maps the specified key to the specified value in this table. * The key can not be NULL. * The value can be retrieved by calling the get method with a key that is equal to the original key. * @param keyName the key * @param value the value */ void SmartDashboard::PutData(const char *keyName, SmartDashboardData *value) { if (keyName == NULL) { wpi_setWPIErrorWithContext(NullParameter, "keyName"); return; } if (value == NULL) { wpi_setWPIErrorWithContext(NullParameter, "value"); return; } NetworkTable *type = new NetworkTable(); type->PutString("~TYPE~", value->GetType()); type->PutSubTable("Data", value->GetTable()); m_table->PutSubTable(keyName, type); m_tablesToData[type] = value; }
/** * Puts the given value into the given key position * @param key the key * @param value the value */ void Preferences::Put(const char *key, std::string value) { std::unique_lock<priority_recursive_mutex> sync(m_tableLock); if (key == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "key"); return; } if (std::string(key).find_first_of("=\n\r \t\"") != std::string::npos) { wpi_setWPIErrorWithContext(ParameterOutOfRange, "key contains illegal characters"); return; } std::pair<StringMap::iterator, bool> ret = m_values.insert(StringMap::value_type(key, value)); if (ret.second) m_keys.push_back(key); else ret.first->second = value; NetworkTable* table = NetworkTable::GetTable(kTableName); table->PutString(key, value); }