Exemplo n.º 1
0
beast::StringPairArray
parseKeyValueSection (Section& secSource, beast::String const& strSection)
{
    beast::StringPairArray result;

    // yuck.
    std::string const stdStrSection (strSection.toStdString ());

    typedef Section::mapped_type Entries;

    Entries* const entries = SectionEntries (secSource, stdStrSection);

    if (entries != nullptr)
    {
        for (Entries::const_iterator iter = entries->begin (); iter != entries->end (); ++iter)
        {
            beast::String const line (iter->c_str ());

            int const equalPos = line.indexOfChar ('=');

            if (equalPos != -1)
            {
                beast::String const key = line.substring (0, equalPos);
                beast::String const value = line.substring (equalPos + 1, line.length ());

                result.set (key, value);
            }
        }
    }

    return result;
}
Exemplo n.º 2
0
void Config::setRpcIpAndOptionalPort (std::string const& newAddress)
{
    beast::String const s (newAddress.c_str ());
    
    int const colonPosition = s.lastIndexOfChar (':');

    if (colonPosition != -1)
    {
        beast::String const ipPart = s.substring (0, colonPosition);
        beast::String const portPart = s.substring (colonPosition + 1, s.length ());

        setRpcIP (ipPart.toRawUTF8 ());
        setRpcPort (portPart.getIntValue ());
    }
    else
    {
        setRpcIP (newAddress);
    }
}