1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[js] std::string -> xmlpp::ustring

This commit is contained in:
Witold Filipczyk 2021-09-08 10:53:12 +02:00
parent 686e83afaa
commit aeb6e064f9
3 changed files with 52 additions and 52 deletions

View File

@ -110,7 +110,7 @@ document_get_property_anchors(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//a";
xmlpp::ustring xpath = "//a";
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
*elements = root->find(xpath);
@ -197,7 +197,7 @@ document_get_property_body(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//body";
xmlpp::ustring xpath = "//body";
xmlpp::Node::NodeSet elements = root->find(xpath);
if (elements.size() == 0) {
@ -324,7 +324,7 @@ document_get_property_charset(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
xmlpp::Document* docu = (xmlpp::Document *)document->dom;
std::string encoding = docu->get_encoding();
xmlpp::ustring encoding = docu->get_encoding();
if (encoding == "") {
encoding = "utf-8";
@ -400,7 +400,7 @@ document_get_property_documentElement(JSContext *ctx, unsigned int argc, JS::Val
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//html";
xmlpp::ustring xpath = "//html";
xmlpp::Node::NodeSet elements = root->find(xpath);
if (elements.size() == 0) {
@ -527,7 +527,7 @@ document_get_property_forms(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//form";
xmlpp::ustring xpath = "//form";
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
*elements = root->find(xpath);
@ -572,7 +572,7 @@ document_get_property_head(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//head";
xmlpp::ustring xpath = "//head";
xmlpp::Node::NodeSet elements = root->find(xpath);
if (elements.size() == 0) {
@ -617,7 +617,7 @@ document_get_property_images(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//img";
xmlpp::ustring xpath = "//img";
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
*elements = root->find(xpath);
@ -662,7 +662,7 @@ document_get_property_links(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//a[@href]|//area[@href]";
xmlpp::ustring xpath = "//a[@href]|//area[@href]";
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
*elements = root->find(xpath);
@ -859,7 +859,7 @@ document_get_property_scripts(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
std::string xpath = "//script";
xmlpp::ustring xpath = "//script";
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
*elements = root->find(xpath);
@ -1357,7 +1357,7 @@ document_createComment(JSContext *ctx, unsigned int argc, JS::Value *vp)
struct string idstr;
init_string(&idstr);
jshandle_value_to_char_string(&idstr, ctx, args[0]);
std::string text = idstr.source;
xmlpp::ustring text = idstr.source;
done_string(&idstr);
xmlpp::CommentNode *comment = emptyRoot->add_child_comment(text);
@ -1406,7 +1406,7 @@ document_createElement(JSContext *ctx, unsigned int argc, JS::Value *vp)
struct string idstr;
init_string(&idstr);
jshandle_value_to_char_string(&idstr, ctx, args[0]);
std::string text = idstr.source;
xmlpp::ustring text = idstr.source;
done_string(&idstr);
xmlpp::Element *elem = emptyRoot->add_child_element(text);
@ -1455,7 +1455,7 @@ document_createTextNode(JSContext *ctx, unsigned int argc, JS::Value *vp)
struct string idstr;
init_string(&idstr);
jshandle_value_to_char_string(&idstr, ctx, args[0]);
std::string text = idstr.source;
xmlpp::ustring text = idstr.source;
done_string(&idstr);
xmlpp::TextNode *textNode = emptyRoot->add_child_text(text);
@ -1505,9 +1505,9 @@ document_getElementById(JSContext *ctx, unsigned int argc, JS::Value *vp)
init_string(&idstr);
jshandle_value_to_char_string(&idstr, ctx, args[0]);
std::string id = idstr.source;
xmlpp::ustring id = idstr.source;
std::string xpath = "//*[@id=\"";
xmlpp::ustring xpath = "//*[@id=\"";
xpath += id;
xpath += "\"]";
@ -1567,9 +1567,9 @@ document_getElementsByClassName(JSContext *ctx, unsigned int argc, JS::Value *vp
init_string(&idstr);
jshandle_value_to_char_string(&idstr, ctx, args[0]);
std::string id = idstr.source;
xmlpp::ustring id = idstr.source;
std::string xpath = "//*[@class=\"";
xmlpp::ustring xpath = "//*[@class=\"";
xpath += id;
xpath += "\"]";
@ -1629,9 +1629,9 @@ document_getElementsByName(JSContext *ctx, unsigned int argc, JS::Value *vp)
init_string(&idstr);
jshandle_value_to_char_string(&idstr, ctx, args[0]);
std::string id = idstr.source;
xmlpp::ustring id = idstr.source;
std::string xpath = "//*[@id=\"";
xmlpp::ustring xpath = "//*[@id=\"";
xpath += id;
xpath += "\"]|//*[@name=\"";
xpath += id;
@ -1692,10 +1692,10 @@ document_getElementsByTagName(JSContext *ctx, unsigned int argc, JS::Value *vp)
init_string(&idstr);
jshandle_value_to_char_string(&idstr, ctx, args[0]);
std::string id = idstr.source;
xmlpp::ustring id = idstr.source;
std::transform(id.begin(), id.end(), id.begin(), ::tolower);
std::string xpath = "//";
xmlpp::ustring xpath = "//";
xpath += id;
done_string(&idstr);
@ -1769,7 +1769,7 @@ doctype_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = dtd->get_name();
xmlpp::ustring v = dtd->get_name();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
@ -1804,7 +1804,7 @@ doctype_get_property_publicId(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = dtd->get_external_id();
xmlpp::ustring v = dtd->get_external_id();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
@ -1839,7 +1839,7 @@ doctype_get_property_systemId(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = dtd->get_system_id();
xmlpp::ustring v = dtd->get_system_id();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;

View File

@ -389,7 +389,7 @@ element_get_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = el->get_attribute_value("class");
xmlpp::ustring v = el->get_attribute_value("class");
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
@ -432,7 +432,7 @@ element_get_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = el->get_attribute_value("dir");
xmlpp::ustring v = el->get_attribute_value("dir");
if (v != "auto" && v != "ltr" && v != "rtl") {
v = "";
@ -585,7 +585,7 @@ element_get_property_id(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = el->get_attribute_value("id");
xmlpp::ustring v = el->get_attribute_value("id");
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
@ -627,7 +627,7 @@ element_get_property_lang(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = el->get_attribute_value("lang");
xmlpp::ustring v = el->get_attribute_value("lang");
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
@ -828,7 +828,7 @@ element_get_property_nodeName(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Node *node = JS_GetPrivate(hobj);
std::string v;
xmlpp::ustring v;
if (!node) {
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
@ -951,7 +951,7 @@ element_get_property_nodeValue(JSContext *ctx, unsigned int argc, JS::Value *vp)
auto el = dynamic_cast<const xmlpp::Attribute*>(node);
if (el) {
std::string v = el->get_value();
xmlpp::ustring v = el->get_value();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
}
@ -959,7 +959,7 @@ element_get_property_nodeValue(JSContext *ctx, unsigned int argc, JS::Value *vp)
auto el2 = dynamic_cast<const xmlpp::TextNode*>(node);
if (el2) {
std::string v = el2->get_content();
xmlpp::ustring v = el2->get_content();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
}
@ -967,7 +967,7 @@ element_get_property_nodeValue(JSContext *ctx, unsigned int argc, JS::Value *vp)
auto el3 = dynamic_cast<const xmlpp::CommentNode*>(node);
if (el3) {
std::string v = el3->get_content();
xmlpp::ustring v = el3->get_content();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
}
@ -1299,7 +1299,7 @@ element_get_property_tagName(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = el->get_name();
xmlpp::ustring v = el->get_name();
std::transform(v.begin(), v.end(), v.begin(), ::toupper);
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
@ -1342,7 +1342,7 @@ element_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = el->get_attribute_value("title");
xmlpp::ustring v = el->get_attribute_value("title");
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
@ -1603,7 +1603,7 @@ element_set_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
char *val = jsval_to_string(ctx, args[0]);
std::string value = val;
xmlpp::ustring value = val;
el->set_attribute("class", value);
interpreter->changed = true;
mem_free_if(val);
@ -1645,7 +1645,7 @@ element_set_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
char *val = jsval_to_string(ctx, args[0]);
std::string value = val;
xmlpp::ustring value = val;
if (value == "ltr" || value == "rtl" || value == "auto") {
el->set_attribute("dir", value);
@ -1691,7 +1691,7 @@ element_set_property_id(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
char *val = jsval_to_string(ctx, args[0]);
std::string value = val;
xmlpp::ustring value = val;
el->set_attribute("id", value);
interpreter->changed = true;
@ -1740,7 +1740,7 @@ element_set_property_innerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Node::remove_node(*it);
}
std::string text = "<root>";
xmlpp::ustring text = "<root>";
char *vv = jsval_to_string(ctx, args[0]);
text += vv;
text += "</root>";
@ -1846,7 +1846,7 @@ element_set_property_lang(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
char *val = jsval_to_string(ctx, args[0]);
std::string value = val;
xmlpp::ustring value = val;
el->set_attribute("lang", value);
interpreter->changed = true;
@ -1952,7 +1952,7 @@ element_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
char *val = jsval_to_string(ctx, args[0]);
std::string value = val;
xmlpp::ustring value = val;
el->set_attribute("title", value);
interpreter->changed = true;
@ -2134,7 +2134,7 @@ element_getAttribute(JSContext *ctx, unsigned int argc, JS::Value *rval)
char *vv = jsval_to_string(ctx, args[0]);
if (vv) {
std::string v = vv;
xmlpp::ustring v = vv;
xmlpp::Attribute *attr = el->get_attribute(v);
if (!attr) {
@ -2178,7 +2178,7 @@ element_getAttributeNode(JSContext *ctx, unsigned int argc, JS::Value *rval)
return true;
}
char *vv = jsval_to_string(ctx, args[0]);
std::string v = vv;
xmlpp::ustring v = vv;
xmlpp::Attribute *attr = el->get_attribute(v);
JSObject *obj = getAttr(ctx, attr);
args.rval().setObject(*obj);
@ -2215,7 +2215,7 @@ element_hasAttribute(JSContext *ctx, unsigned int argc, JS::Value *rval)
return true;
}
char *vv = jsval_to_string(ctx, args[0]);
std::string v = vv;
xmlpp::ustring v = vv;
xmlpp::Attribute *attr = el->get_attribute(v);
args.rval().setBoolean((bool)attr);
@ -2476,9 +2476,9 @@ element_setAttribute(JSContext *ctx, unsigned int argc, JS::Value *rval)
if (args[0].isString() && args[1].isString()) {
char *attr_c = jsval_to_string(ctx, args[0]);
std::string attr = attr_c;
xmlpp::ustring attr = attr_c;
char *value_c = jsval_to_string(ctx, args[1]);
std::string value = value_c;
xmlpp::ustring value = value_c;
el->set_attribute(attr, value);
interpreter->changed = true;
mem_free_if(attr_c);
@ -2689,7 +2689,7 @@ htmlCollection_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *str, JS::
return true;
}
std::string name = str;
xmlpp::ustring name = str;
auto it = ns->begin();
auto end = ns->end();
@ -2750,7 +2750,7 @@ htmlCollection_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId
char *string = jsval_to_string(ctx, r_idval);
if (string) {
std::string test = string;
xmlpp::ustring test = string;
if (test != "item" && test != "namedItem") {
bool ret = htmlCollection_namedItem2(ctx, hobj, string, hvp);
@ -3167,7 +3167,7 @@ attributes_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *str, JS::Muta
return true;
}
std::string name = str;
xmlpp::ustring name = str;
auto it = al->begin();
auto end = al->end();
@ -3318,7 +3318,7 @@ attr_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = attr->get_name();
xmlpp::ustring v = attr->get_name();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;
@ -3360,7 +3360,7 @@ attr_get_property_value(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
std::string v = attr->get_value();
xmlpp::ustring v = attr->get_value();
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
return true;

View File

@ -47,7 +47,7 @@
#include "viewer/text/link.h"
#include "viewer/text/vs.h"
#include <string>
#include <libxml++/libxml++.h>
//static JSClass form_class; /* defined below */
@ -1813,7 +1813,7 @@ form_elements_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId h
char *string = jsval_to_string(ctx, r_idval);
if (string) {
std::string test = string;
xmlpp::ustring test = string;
if (test == "item" || test == "namedItem") {
mem_free(string);
return true;
@ -3003,7 +3003,7 @@ forms_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::
if (JSID_IS_STRING(hid)) {
char *string = jsid_to_string(ctx, hid);
std::string test = string;
xmlpp::ustring test = string;
if (test == "item" || test == "namedItem") {
return true;