std::string SonicDBConfig::getSeparator()

in common/dbconnector.cpp [344:374]


std::string SonicDBConfig::getSeparator(int dbId, const SonicDBKey &key)
{
    std::lock_guard<std::recursive_mutex> guard(m_db_info_mutex);

    if (!m_init)
        initialize(DEFAULT_SONIC_DB_CONFIG_FILE);

    if (!key.isEmpty())
    {
        if (!m_global_init)
        {
            SWSS_LOG_THROW("Initialize global DB config using API SonicDBConfig::initializeGlobalConfig");
        }
    }
    auto foundEntry = m_db_separator.find(key);
    if (foundEntry == m_db_separator.end())
    {
        string msg = "Key " + key.toString() + " is not a valid key name in config file";
        SWSS_LOG_ERROR("%s", msg.c_str());
        throw out_of_range(msg);
    }
    auto seps = foundEntry->second;
    auto foundDb = seps.find(dbId);
    if (foundDb == seps.end())
    {
        string msg = "Failed to find " + to_string(dbId) + " database in " + key.toString() + " key";
        SWSS_LOG_ERROR("%s", msg.c_str());
        throw out_of_range(msg);
    }
    return foundDb->second;
}