本文整理汇总了C++中CharacterData::replaceData方法的典型用法代码示例。如果您正苦于以下问题:C++ CharacterData::replaceData方法的具体用法?C++ CharacterData::replaceData怎么用?C++ CharacterData::replaceData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharacterData
的用法示例。
在下文中一共展示了CharacterData::replaceData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
String childData;
doc = (Document) baseT::load("staff", true);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
nameNode = elementList.item(0);
child = (CharacterData) nameNode.getFirstChild();
child.replaceData(0, 4, SA::construct_from_utf8("2500"));
childData = child.getData();
baseT::assertEquals("2500 North Ave. Dallas, Texas 98551", childData, __LINE__, __FILE__);
}
示例2: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
doc = (Document) baseT::load("staff", true);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
nameNode = elementList.item(0);
child = (CharacterData) nameNode.getFirstChild();
{
boolean success = false;
try {
child.replaceData(-5, 3, SA::construct_from_utf8("ABC"));
} catch (const DOMException& ex) {
success = (ex.code() == DOMException::INDEX_SIZE_ERR);
}
assertTrue(success);
}
}
示例3: jsCharacterDataPrototypeFunctionReplaceData
JSValue* jsCharacterDataPrototypeFunctionReplaceData(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSCharacterData::s_info))
return throwError(exec, TypeError);
JSCharacterData* castedThisObj = static_cast<JSCharacterData*>(thisValue);
CharacterData* imp = static_cast<CharacterData*>(castedThisObj->impl());
ExceptionCode ec = 0;
int offset = args.at(exec, 0)->toInt32(exec);
if (offset < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
int length = args.at(exec, 1)->toInt32(exec);
if (length < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
const UString& data = args.at(exec, 2)->toString(exec);
imp->replaceData(offset, length, data, ec);
setDOMException(exec, ec);
return jsUndefined();
}
示例4: callAsFunction
//.........这里部分代码省略.........
bool lengthOk;
int length = args[1]->toInt32(exec, lengthOk);
if (!lengthOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
if (length < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
KJS::JSValue* result = jsStringOrNull(imp->substringData(offset, length, ec));
setDOMException(exec, ec);
return result;
}
case JSCharacterData::AppendDataFuncNum: {
ExceptionCode ec = 0;
String data = args[0]->toString(exec);
imp->appendData(data, ec);
setDOMException(exec, ec);
return jsUndefined();
}
case JSCharacterData::InsertDataFuncNum: {
ExceptionCode ec = 0;
bool offsetOk;
int offset = args[0]->toInt32(exec, offsetOk);
if (!offsetOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
if (offset < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
String data = args[1]->toString(exec);
imp->insertData(offset, data, ec);
setDOMException(exec, ec);
return jsUndefined();
}
case JSCharacterData::DeleteDataFuncNum: {
ExceptionCode ec = 0;
bool offsetOk;
int offset = args[0]->toInt32(exec, offsetOk);
if (!offsetOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
if (offset < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
bool lengthOk;
int length = args[1]->toInt32(exec, lengthOk);
if (!lengthOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
if (length < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
imp->deleteData(offset, length, ec);
setDOMException(exec, ec);
return jsUndefined();
}
case JSCharacterData::ReplaceDataFuncNum: {
ExceptionCode ec = 0;
bool offsetOk;
int offset = args[0]->toInt32(exec, offsetOk);
if (!offsetOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
if (offset < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
bool lengthOk;
int length = args[1]->toInt32(exec, lengthOk);
if (!lengthOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
if (length < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return jsUndefined();
}
String data = args[2]->toString(exec);
imp->replaceData(offset, length, data, ec);
setDOMException(exec, ec);
return jsUndefined();
}
}
return 0;
}