result_t XmlComment::toString(exlib::string &retVal) { retVal = "<!--"; retVal.append(m_data.data()); retVal.append("-->"); return 0; }
result_t Url::get_auth(exlib::string& retVal) { exlib::string str; encoding_base::encodeURIComponent(m_username, str); retVal = str; if (m_password.length() > 0) { retVal.append(1, ':'); encoding_base::encodeURIComponent(m_password, str); retVal.append(str); } return 0; }
result_t XmlElement::toString(exlib::string& retVal) { retVal = "<"; exlib::string tagName(m_tagName); if (!m_isXml) qstrlwr(&tagName[0]); if (m_prefix.empty()) { if (!m_namespaceURI.empty()) { bool skip_def_ns = false; if (m_parent) { int32_t type; m_parent->get_nodeType(type); if (type == xml_base::_ELEMENT_NODE) { exlib::string def_ns; ((XmlElement*)m_parent->m_node)->get_defaultNamespace(def_ns); if (def_ns == m_namespaceURI) skip_def_ns = true; } } if (!skip_def_ns) setAttribute("xmlns", m_namespaceURI); } retVal.append(tagName); } else { fix_prefix(m_namespaceURI, m_prefix); retVal.append(m_prefix); retVal += ':'; retVal.append(m_localName); } exlib::string strAttr; m_attrs->toString(strAttr); retVal.append(strAttr); if (m_childs->hasChildNodes()) { exlib::string strChild; m_childs->toString(strChild); retVal += '>'; retVal.append(strChild); retVal.append("</"); retVal.append(tagName); retVal += '>'; } else retVal.append("/>"); return 0; }
result_t Url::get_href(exlib::string& retVal) { retVal.clear(); if (m_protocol.length() > 0) retVal.append(m_protocol); if (m_slashes) retVal.append("//", 2); exlib::string str; if (m_username.length() > 0) { get_auth(str); retVal.append(str); retVal.append(1, '@'); } get_host(str); retVal.append(str); get_path(str); retVal.append(str); retVal.append(m_hash); return 0; }
result_t Url::get_search(exlib::string& retVal) { if (m_query.length() > 0) { retVal.assign(1, '?'); retVal.append(m_query); } return 0; }
result_t X509Cert::get_type(exlib::string &retVal) { mbedtls_x509_crt *crt = get_crt(); if (!crt) return CHECK_ERROR(CALL_E_INVALID_CALL); int32_t cert_type = crt->ns_cert_type; int32_t i; for (i = 0; i < (int32_t)ARRAYSIZE(g_types); i ++) { if (cert_type & g_types[i].id) { if (!retVal.empty()) retVal.append(", ", 2); retVal.append(g_types[i].name); } } return 0; }
void _appendValue(exlib::string& str, v8::Local<v8::Value>& v, bool mysql) { bool bNumber = v->IsNumber() || v->IsNumberObject(); if (bNumber) { v8::String::Utf8Value s1(v); str.append(*s1, s1.length()); } else { exlib::string s; str += '\''; if (v->IsDate()) { date_t d = v; d.sqlString(s); } else { v8::String::Utf8Value s1(v); _escape(*s1, s1.length(), mysql, s); } str.append(s); str += '\''; } }
result_t base64vlq_base::encode(int32_t data, exlib::string& retVal) { static const char encodeTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; if (data < 0) data = ((-data) << 1) | 1; else data <<= 1; do { int32_t byte = data & 0x1f; data >>= 5; if (data) byte |= 0x20; retVal.append(1, encodeTable[byte]); } while (data > 0); return 0; }
result_t path_base::get_delimiter(exlib::string &retVal) { retVal.clear(); retVal.append(1, PATH_DELIMITER); return 0; }
result_t path_base::get_sep(exlib::string &retVal) { retVal.clear(); retVal.append(1, PATH_SLASH); return 0; }