///\param xml the xml node
///\param name the name of the child
///\param off the offset
-#define switch_xml_add_child_d(xml, name, off) \
- switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)
+SWITCH_DECLARE(switch_xml_t) switch_xml_add_child_d(_In_ switch_xml_t xml, _In_z_ const char *name, _In_ switch_size_t off);
///\brief sets the character content for the given tag and returns the tag
///\param xml the xml node
///\param xml the xml node
///\param txt the text
///\return an xml node or NULL
-#define switch_xml_set_txt_d(xml, txt) \
- switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt_d(switch_xml_t xml, const char *txt);
///\brief Sets the given tag attribute or adds a new attribute if not found. A value
///\ of NULL will remove the specified attribute.
///\param name the attribute name
///\param value the attribute value
///\return an xml node or NULL
-#define switch_xml_set_attr_d(xml, name, value) \
- switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(switch_str_nil(value)))
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d(switch_xml_t xml, const char *name, const char *value);
-#define switch_xml_set_attr_d_buf(xml, name, value) \
- switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
+///\brief Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
+///\param xml the xml node
+///\param name the attribute name
+///\param value the attribute value
+///\return an xml node or NULL
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d_buf(switch_xml_t xml, const char *name, const char *value);
///\brief sets a flag for the given tag and returns the tag
///\param xml the xml node
switch_snprintf(id, sizeof(id), "%d", holder->rows);
- switch_xml_set_attr(switch_xml_set_flag(row, SWITCH_XML_DUP), strdup("row_id"), strdup(id));
+ switch_xml_set_attr_d_buf(row, "row_id", id);
for (x = 0; x < argc; x++) {
char *name = columnNames[x];
char *xmlstr;
switch_snprintf(count, sizeof(count), "%d", holder.count);
- switch_xml_set_attr(switch_xml_set_flag(holder.xml, SWITCH_XML_DUP), strdup("row_count"), strdup(count));
+ switch_xml_set_attr(holder.xml, "row_count", count);
xmlstr = switch_xml_toxml(holder.xml, SWITCH_FALSE);
switch_xml_free(holder.xml);
return switch_xml_insert(child, xml, off);
}
+/* Adds a child tag. off is the offset of the child tag relative to the start
+ of the parent tag's character content. Returns the child tag */
+SWITCH_DECLARE(switch_xml_t) switch_xml_add_child_d(switch_xml_t xml, const char *name, switch_size_t off)
+{
+ if (!xml) return NULL;
+ return switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM);
+}
+
/* sets the character content for the given tag and returns the tag */
SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *txt)
{
return xml;
}
+/* sets the character content for the given tag and returns the tag */
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt_d(switch_xml_t xml, const char *txt)
+{
+ if (!xml) return NULL;
+ return switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM);
+}
+
/* Sets the given tag attribute or adds a new attribute if not found. A value
of NULL will remove the specified attribute. Returns the tag given */
SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value)
return xml;
}
+/* Sets the given tag attribute or adds a new attribute if not found. A value
+ of NULL will remove the specified attribute. Returns the tag given */
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d(switch_xml_t xml, const char *name, const char *value)
+{
+ if (!xml) return NULL;
+ return switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(switch_str_nil(value)));
+}
+
+/* Sets the given tag attribute or adds a new attribute if not found. A value
+ of NULL will remove the specified attribute. Returns the tag given */
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d_buf(switch_xml_t xml, const char *name, const char *value)
+{
+ if (!xml) return NULL;
+ return switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value));
+}
+
/* sets a flag for the given tag and returns the tag */
SWITCH_DECLARE(switch_xml_t) switch_xml_set_flag(switch_xml_t xml, switch_xml_flag_t flag)
{