Beispiel #1
0
std::vector<STBase const*>
STObject::getSortedFields (STObject const& objToSort)
{
    std::vector<STBase const*> sf;
    sf.reserve (objToSort.getCount ());

    // Choose the fields that we need to sort.
    for (detail::STVar const& elem : objToSort.v_)
    {
        // Pick out the fields and sort them.
        STBase const& base = elem.get();
        if ((base.getSType () != STI_NOTPRESENT) &&
            base.getFName ().shouldInclude (true))
        {
            sf.push_back (&base);
        }
    }

    // Sort the fields by fieldCode.
    std::sort (sf.begin (), sf.end (),
        [] (STBase const* a, STBase const* b) -> bool
        {
            return a->getFName ().fieldCode < b->getFName ().fieldCode;
        });

    // There should never be duplicate fields in an STObject. Verify that
    // in debug mode.
    assert (std::adjacent_find (sf.cbegin (), sf.cend ()) == sf.cend ());

    return sf;
}
Beispiel #2
0
// Ensure all account fields are 160-bits
static
bool
isAccountFieldOkay (STObject const& st)
{
    for (int i = 0; i < st.getCount(); ++i)
    {
        auto t = dynamic_cast<STAccount const*>(st.peekAtPIndex (i));
        if (t && t->isDefault ())
            return false;
    }

    return true;
}