Exemple #1
0
std::string Toolkit::GetElementAttr( const std::string &xmlId )
{
#ifdef USE_EMSCRIPTEN
    jsonxx::Object o;

    if ( !m_doc.GetDrawingPage() ) return o.json();
    Object *element = m_doc.GetDrawingPage()->FindChildByUuid(xmlId);
    if (!element) {
        LogMessage("Element with id '%s' could not be found", xmlId.c_str() );
        return o.json();
    }

    // Fill the attribute array (pair of string) by looking by attributes for all available MEI modules
    ArrayOfStrAttr attributes;
    element->GetAttributes(&attributes);

    // Fill the JSON object
    ArrayOfStrAttr::iterator iter;
    for (iter = attributes.begin(); iter != attributes.end(); iter++) {
        o << (*iter).first << (*iter).second;
        //LogMessage("Element %s - %s", (*iter).first.c_str(), (*iter).second.c_str() );
    }
    return o.json();

#else
    // The non js version of the app should not use this function.
    return "";
#endif
}
Exemple #2
0
bool Object::HasAttribute( std::string attribute, std::string value )
{
    ArrayOfStrAttr attributes;
    this->GetAttributes( &attributes );
    ArrayOfStrAttr::iterator iter;
    for (iter = attributes.begin(); iter != attributes.end(); iter++) {
        if ( ( (*iter).first == attribute ) && ( (*iter).second == value ) ) return true;
    }
    return false;
}