本文整理汇总了C++中CharacterData类的典型用法代码示例。如果您正苦于以下问题:C++ CharacterData类的具体用法?C++ CharacterData怎么用?C++ CharacterData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CharacterData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Element testEmployee;
Node firstC;
String childName;
int nodeType;
CharacterData employeeIDNode;
String employeeID;
doc = (Document) baseT::load("hc_staff", false);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("p"));
testEmployee = (Element) elementList.item(3);
firstC = testEmployee.getFirstChild();
nodeType = (int) firstC.getNodeType();
while (baseT::equals(3, nodeType)) {
firstC = firstC.getNextSibling();
nodeType = (int) firstC.getNodeType();
}
childName = firstC.getNodeName();
baseT::assertEquals("em", childName, __LINE__, __FILE__);
employeeIDNode = (CharacterData) firstC.getFirstChild();
employeeID = employeeIDNode.getNodeValue();
baseT::assertEquals("EMP0004", employeeID, __LINE__, __FILE__);
}
示例2: reply
void ChatHandler::handleGuildMemberLevelChange(ChatClient &client,
MessageIn &msg)
{
// get the guild, the user to change the permissions, and the new permission
// check theyre valid, and then change them
MessageOut reply(CPMSG_GUILD_PROMOTE_MEMBER_RESPONSE);
short guildId = msg.readInt16();
std::string user = msg.readString();
short level = msg.readInt8();
Guild *guild = guildManager->findById(guildId);
CharacterData *c = storage->getCharacter(user);
if (guild && c)
{
int rights = guild->getUserPermissions(c->getDatabaseID()) | level;
if (guildManager->changeMemberLevel(&client, guild, c->getDatabaseID(),
rights) == 0)
{
reply.writeInt8(ERRMSG_OK);
client.send(reply);
}
}
reply.writeInt8(ERRMSG_FAILURE);
client.send(reply);
}
示例3: applyData
void CharacterData::applyData(CharacterData data, CharacterData originalData)
{
this->attack=data.attack;
this->attack = MAX(this->attack,0);
this->defense=data.defense;
this->defense = MAX(this->defense,0);
this->speed=data.speed;
this->speed = MAX(this->speed,0);
this->jumpHeight=data.jumpHeight;
this->jumpHeight = MAX(this->jumpHeight,0);
this->attackSpeed=data.attackSpeed;
this->attackSpeed = MAX(this->attackSpeed,0);
this->maxJumpTimes=data.maxJumpTimes;
this->maxJumpTimes = MAX(this->maxJumpTimes,0);
if(data.getHealth()>0)
{
this->health+= data.health;
this->health = MIN(this->health,originalData.getHealth());
}
else
{
this->health+= MIN((data.getHealth()+this->getDefense()),0);
}
// this->health = MAX(this->health,0);
}
示例4: currentNode
void HTMLConstructionSite::insertTextNode(const String& characters)
{
AttachmentSite site;
site.parent = currentNode();
site.nextChild = 0;
if (shouldFosterParent())
findFosterSite(site);
unsigned currentPosition = 0;
// FIXME: Splitting text nodes into smaller chunks contradicts HTML5 spec, but is currently necessary
// for performance, see <https://bugs.webkit.org/show_bug.cgi?id=55898>.
Node* previousChild = site.nextChild ? site.nextChild->previousSibling() : site.parent->lastChild();
if (previousChild && previousChild->isTextNode()) {
// FIXME: We're only supposed to append to this text node if it
// was the last text node inserted by the parser.
CharacterData* textNode = static_cast<CharacterData*>(previousChild);
currentPosition = textNode->parserAppendData(characters.characters(), characters.length(), Text::defaultLengthLimit);
}
while (currentPosition < characters.length()) {
RefPtr<Text> textNode = Text::createWithLengthLimit(site.parent->document(), characters, currentPosition);
// If we have a whole string of unbreakable characters the above could lead to an infinite loop. Exceeding the length limit is the lesser evil.
if (!textNode->length())
textNode = Text::create(site.parent->document(), characters.substring(currentPosition));
currentPosition += textNode->length();
ASSERT(currentPosition <= characters.length());
attachAtSite(site, textNode.release());
}
}
示例5:
EveApi::CharacterData::CharacterData ( const CharacterData& other ):
_name(other.name()),
_characterID(other.characterID()),
_corporationName(other.corporationName()),
_corporationID(other.corporationID())
{
}
示例6: GetSourceFrameForCharacter
SourceFrame BitmapFont::GetSourceFrameForCharacter(char aCharacter)
{
CharacterData* characterData = m_CharacterData[aCharacter];
if(characterData != nullptr)
{
return characterData->GetSourceFrame();
}
return SourceFrame(0.0f, 0.0f, 0.0f, 0.0f);
}
示例7: GetBearingYForCharacter
char BitmapFont::GetBearingYForCharacter(char aCharacter)
{
CharacterData* characterData = m_CharacterData[aCharacter];
if(characterData != nullptr)
{
return (char)characterData->GetOffset().y;
}
return 0;
}
示例8: GetAdvanceXForCharacter
unsigned short BitmapFont::GetAdvanceXForCharacter(char aCharacter)
{
CharacterData* characterData = m_CharacterData[aCharacter];
if(characterData != nullptr)
{
return characterData->GetAdvanceX();
}
return 0;
}
示例9: switch
void JSCharacterData::putValueProperty(ExecState* exec, int token, JSValue* value)
{
switch (token) {
case DataAttrNum: {
CharacterData* imp = static_cast<CharacterData*>(impl());
ExceptionCode ec = 0;
imp->setData(valueToStringWithNullCheck(exec, value), ec);
setDOMException(exec, ec);
break;
}
}
}
示例10: jsCharacterDataPrototypeFunctionAppendData
JSValue* jsCharacterDataPrototypeFunctionAppendData(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;
const UString& data = args.at(exec, 0)->toString(exec);
imp->appendData(data, ec);
setDOMException(exec, ec);
return jsUndefined();
}
示例11: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
String childData;
doc = (Document) baseT::load("staff", false);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("name"));
nameNode = elementList.item(0);
child = (CharacterData) nameNode.getFirstChild();
childData = child.getData();
baseT::assertEquals("Margaret Martin", childData, __LINE__, __FILE__);
}
示例12: 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(30, 5, SA::construct_from_utf8("98665"));
childData = child.getData();
baseT::assertEquals("1230 North Ave. Dallas, Texas 98665", childData, __LINE__, __FILE__);
}
示例13: MaybeCreate
// static
already_AddRefed<DeleteTextTransaction>
DeleteTextTransaction::MaybeCreateForPreviousCharacter(
EditorBase& aEditorBase,
CharacterData& aCharData,
uint32_t aOffset)
{
if (NS_WARN_IF(!aOffset)) {
return nullptr;
}
nsAutoString data;
aCharData.GetData(data);
if (NS_WARN_IF(data.IsEmpty())) {
return nullptr;
}
uint32_t length = 1;
uint32_t offset = aOffset - 1;
if (offset &&
NS_IS_LOW_SURROGATE(data[offset]) &&
NS_IS_HIGH_SURROGATE(data[offset - 1])) {
++length;
--offset;
}
return DeleteTextTransaction::MaybeCreate(aEditorBase, aCharData,
offset, length);
}
示例14: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
String childData;
doc = (Document) baseT::load("hc_staff", true);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
nameNode = elementList.item(0);
child = (CharacterData) nameNode.getFirstChild();
child.deleteData(0, 16);
childData = child.getData();
baseT::assertEquals("Dallas, Texas 98551", childData, __LINE__, __FILE__);
}
示例15: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
String childValue;
int childLength;
doc = (Document) baseT::load("staff", false);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("name"));
nameNode = elementList.item(0);
child = (CharacterData) nameNode.getFirstChild();
childValue = child.getData();
childLength = SA::length(childValue);
baseT::assertEquals(15, childLength, __LINE__, __FILE__);
}