const vector<string>& ExtensibleAttribute::getSerializedValues() const { if (m_serialized.empty()) { const char* formatter = m_obj["_formatter"].string(); if (formatter) { string msg = formatter; DDF val = m_obj.first().first(); while (!val.isnull()) { static const char* legal="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_.[]"; m_serialized.push_back(string()); string& processed = m_serialized.back(); string::size_type i=0,start=0; while (start!=string::npos && start<msg.length() && (i=msg.find("$",start))!=string::npos) { if (i>start) processed += msg.substr(start,i-start); // append everything in between start=i+1; // move start to the beginning of the token name i=msg.find_first_not_of(legal,start); // find token delimiter if (i==start) { // append a non legal character processed+=msg[start++]; continue; } string tag = msg.substr(start,(i==string::npos) ? i : i-start); if (tag == "_string" && val.string()) { processed += val.string(); start=i; } else { DDF child = val.getmember(tag.c_str()); if (child.string()) processed += child.string(); else if (child.isstruct() && child["_string"].string()) processed += child["_string"].string(); start=i; } } if (start!=string::npos && start<msg.length()) processed += msg.substr(start,i); // append rest of string val = m_obj.first().next(); } } } return Attribute::getSerializedValues(); }
DDF DDF::getmember(const char* path) const { char name[MAX_NAME_LEN+1]; const char* path_ptr=path; DDF current; if (isstruct() && ddf_strlen(ddf_token(&path_ptr,name))>0) { current.m_handle=m_handle->value.children.first; while (current.m_handle && strcmp(current.m_handle->name,name)!=0) current.m_handle=current.m_handle->next; if (current.m_handle && ddf_strlen(path_ptr)>0) current=current.getmember(path_ptr); } return current; }