本文整理汇总了C++中XmlElement::getText方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlElement::getText方法的具体用法?C++ XmlElement::getText怎么用?C++ XmlElement::getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlElement
的用法示例。
在下文中一共展示了XmlElement::getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
Error CollisionResource::load(const ResourceFilename& filename)
{
XmlElement el;
XmlDocument doc;
ANKI_CHECK(openFileParseXml(filename, doc));
XmlElement collEl;
ANKI_CHECK(doc.getChildElement("collisionShape", collEl));
ANKI_CHECK(collEl.getChildElement("type", el));
CString type;
ANKI_CHECK(el.getText(type));
XmlElement valEl;
ANKI_CHECK(collEl.getChildElement("value", valEl));
PhysicsWorld& physics = getManager().getPhysicsWorld();
PhysicsCollisionShapeInitInfo csInit;
if(type == "sphere")
{
F64 tmp;
ANKI_CHECK(valEl.getF64(tmp));
m_physicsShape = physics.newInstance<PhysicsSphere>(csInit, tmp);
}
else if(type == "box")
{
Vec3 extend;
ANKI_CHECK(valEl.getVec3(extend));
m_physicsShape = physics.newInstance<PhysicsBox>(csInit, extend);
}
else if(type == "staticMesh")
{
CString meshfname;
ANKI_CHECK(valEl.getText(meshfname));
MeshLoader loader(&getManager());
ANKI_CHECK(loader.load(meshfname));
m_physicsShape = physics.newInstance<PhysicsTriangleSoup>(csInit,
reinterpret_cast<const Vec3*>(loader.getVertexData()),
loader.getVertexSize(),
reinterpret_cast<const U16*>(loader.getIndexData()),
loader.getHeader().m_totalIndicesCount);
}
else
{
ANKI_LOGE("Incorrect collision type");
return ErrorCode::USER_DATA;
}
return ErrorCode::NONE;
}
示例2: createAttribute
THIS::THIS(XmlElement* h):Element(h){
/* attributes */
createAttribute(attrib_sid,"sid");
/** children**/
/* data */
XmlElement* element = handle;
if(element){
Utils::fromString(value,element->getText());
}
}
示例3:
THIS::THIS(XmlElement* h):Element(h){
/* attributes */
/* children */
/* data */
XmlElement* element = handle;
if(element){
Utils::fromString(indices,element->getText());
}
}
示例4: createAttribute
THIS::THIS(XmlElement* h):Element(h){
/* attributes */
createAttribute(attrib_count,"count");
createAttribute(attrib_id,"id");
createAttribute(attrib_name,"name");
/* children */
XmlElement* element = handle;
if(element){
Utils::fromString(values,element->getText());
}
}
示例5: buildChildren
THIS::THIS(XmlElement* h):Element(h){
/* attributes */
/* children */
buildChildren(Types());
/* data */
XmlElement* element = handle;
if(element){
Utils::fromString(data,element->getText());
}
}
示例6: load
//==============================================================================
void Skeleton::load(const CString& filename, ResourceInitializer& init)
{
XmlDocument doc;
doc.loadFile(filename, init.m_tempAlloc);
XmlElement rootEl = doc.getChildElement("skeleton");
XmlElement bonesEl = rootEl.getChildElement("bones");
// count the bones count
U bonesCount = 0;
XmlElement boneEl = bonesEl.getChildElement("bone");
do
{
++bonesCount;
boneEl = boneEl.getNextSiblingElement("bone");
} while(boneEl);
// Alloc the vector
m_bones = std::move(ResourceVector<Bone>(init.m_alloc));
m_bones.resize(bonesCount, Bone(init.m_alloc));
// Load every bone
boneEl = bonesEl.getChildElement("bone");
bonesCount = 0;
do
{
Bone& bone = m_bones[bonesCount++];
// <name>
XmlElement nameEl = boneEl.getChildElement("name");
bone.m_name = nameEl.getText();
// <transform>
XmlElement trfEl = boneEl.getChildElement("transform");
bone.m_transform = trfEl.getMat4();
// Advance
boneEl = boneEl.getNextSiblingElement("bone");
} while(boneEl);
}
示例7: createAttribute
THIS::THIS(XmlElement* h):Element(h){
/* attributes */
createAttribute(attrib_count,"count");
createAttribute(attrib_id,"id");
createAttribute(attrib_name,"name");
/* data */
XmlElement* element = handle;
if(element){
std::vector<std::string> strings;
Utils::fromString(strings,element->getText());
std::vector<std::string>::iterator iter;
for(iter = strings.begin(); iter != strings.end(); iter++){
values.push_back((*iter) == "true" ? true : false);
}
}
}
示例8: buildChildren
THIS::THIS(XmlElement* h):Element(h){
/* attributes */
/* children */
buildChildren(Types());
/* data */
XmlElement* element = handle;
if(element){
std::string str = element->getText();
/*remove spaces*/
while(str.find(" ") != std::string::npos)
{
str.replace(str.find(" "), 1, "");
}
/*default*/
data = Enum::LINEAR;
if(str == "NEAREST"){
data = Enum::NEAREST;
}
}
}
示例9: parseOperationTag
//==============================================================================
void MaterialProgramCreator::parseOperationTag(
const XmlElement& operationTag, GLenum glshader, GLbitfield glshaderbit,
MPString& out)
{
static const char OUT[] = {"out"};
// <id></id>
I id = operationTag.getChildElement("id").getInt();
// <returnType></returnType>
XmlElement retTypeEl = operationTag.getChildElement("returnType");
MPString retType(retTypeEl.getText(), m_alloc);
MPString operationOut(m_alloc);
if(retType != "void")
{
MPString tmp(MPString::toString(id, m_alloc));
operationOut = ANKI_STRL(OUT) + tmp;
}
// <function>functionName</function>
MPString funcName(
operationTag.getChildElement("function").getText(), m_alloc);
// <arguments></arguments>
XmlElement argsEl = operationTag.getChildElementOptional("arguments");
MPStringList argsList(m_alloc);
if(argsEl)
{
// Get all arguments
XmlElement argEl = argsEl.getChildElement("argument");
do
{
MPString arg(argEl.getText(), m_alloc);
// Search for all the inputs and mark the appropriate
Input* input = nullptr;
for(Input& in : m_inputs)
{
// Check that the first part of the string is equal to the
// variable and the following char is '['
if(in.m_name == arg)
{
input = ∈
in.m_shaderReferencedMask = glshaderbit;
break;
}
}
// The argument should be an input variable or an outXX
if(!(input != nullptr
|| std::strncmp(&arg[0], OUT, sizeof(OUT) - 1) == 0))
{
throw ANKI_EXCEPTION("Incorrect argument: %s", &arg[0]);
}
// Add to a list and do something special if instanced
if(input && input->m_instanced)
{
if(glshader == GL_VERTEX_SHADER)
{
argsList.push_back(ANKI_STRL(argEl.getText())
+ "[gl_InstanceID]");
m_instanceIdMask |= glshaderbit;
}
else if(glshader == GL_TESS_CONTROL_SHADER)
{
argsList.push_back(ANKI_STRL(argEl.getText())
+ "[vInstanceId[0]]");
m_instanceIdMask |= glshaderbit;
}
else if(glshader == GL_TESS_EVALUATION_SHADER)
{
argsList.push_back(ANKI_STRL(argEl.getText())
+ "[commonPatch.instanceId]");
m_instanceIdMask |= glshaderbit;
}
else if(glshader == GL_FRAGMENT_SHADER)
{
argsList.push_back(ANKI_STRL(argEl.getText())
+ "[vInstanceId]");
m_instanceIdMask |= glshaderbit;
}
else
{
throw ANKI_EXCEPTION(
"Cannot access the instance ID in all shaders");
}
}
else
{
argsList.push_back(MPString(argEl.getText(), m_alloc));
}
// Advance
//.........这里部分代码省略.........
示例10: getSubElement
std::string
XmlElement::getSubElementText( const std::string& name ) const
{
XmlElement* e = getSubElement( name );
return e? e->getText() : EMPTY_VALUE;
}
示例11: parseMaterialTag
//==============================================================================
Error Material::parseMaterialTag(const XmlElement& materialEl,
ResourceInitializer& rinit)
{
Error err = ErrorCode::NONE;
XmlElement el;
// levelsOfDetail
//
XmlElement lodEl;
ANKI_CHECK(materialEl.getChildElementOptional("levelsOfDetail", lodEl));
if(lodEl)
{
I64 tmp;
ANKI_CHECK(lodEl.getI64(tmp));
m_lodsCount = (tmp < 1) ? 1 : tmp;
}
else
{
m_lodsCount = 1;
}
// shadow
//
XmlElement shadowEl;
ANKI_CHECK(materialEl.getChildElementOptional("shadow", shadowEl));
if(shadowEl)
{
I64 tmp;
ANKI_CHECK(shadowEl.getI64(tmp));
m_shadow = tmp;
}
// blendFunctions
//
XmlElement blendFunctionsEl;
ANKI_CHECK(
materialEl.getChildElementOptional("blendFunctions", blendFunctionsEl));
if(blendFunctionsEl)
{
CString cstr;
// sFactor
ANKI_CHECK(blendFunctionsEl.getChildElement("sFactor", el));
ANKI_CHECK(el.getText(cstr));
m_blendingSfactor = blendToEnum(cstr);
if(m_blendingSfactor == 0)
{
return ErrorCode::USER_DATA;
}
// dFactor
ANKI_CHECK(blendFunctionsEl.getChildElement("dFactor", el));
ANKI_CHECK(el.getText(cstr));
m_blendingDfactor = blendToEnum(cstr);
if(m_blendingDfactor == 0)
{
return ErrorCode::USER_DATA;
}
}
else
{
m_passesCount = 2;
}
// depthTesting
//
XmlElement depthTestingEl;
ANKI_CHECK(
materialEl.getChildElementOptional("depthTesting", depthTestingEl));
if(depthTestingEl)
{
I64 tmp;
ANKI_CHECK(depthTestingEl.getI64(tmp));
m_depthTesting = tmp;
}
// wireframe
//
XmlElement wireframeEl;
ANKI_CHECK(materialEl.getChildElementOptional("wireframe", wireframeEl));
if(wireframeEl)
{
I64 tmp;
ANKI_CHECK(wireframeEl.getI64(tmp));
m_wireframe = tmp;
}
// shaderProgram
//
ANKI_CHECK(materialEl.getChildElement("programs", el));
MaterialProgramCreator loader(rinit.m_tempAlloc);
ANKI_CHECK(loader.parseProgramsTag(el));
m_tessellation = loader.hasTessellation();
//.........这里部分代码省略.........
示例12: load
//==============================================================================
Error ParticleEmitterResource::load(const CString& filename)
{
U32 tmp;
XmlDocument doc;
ANKI_CHECK(doc.loadFile(filename, getTempAllocator()));
XmlElement rel; // Root element
ANKI_CHECK(doc.getChildElement("particleEmitter", rel));
// XML load
//
ANKI_CHECK(xmlF32(rel, "life", m_particle.m_life));
ANKI_CHECK(xmlF32(rel, "lifeDeviation", m_particle.m_lifeDeviation));
ANKI_CHECK(xmlF32(rel, "mass", m_particle.m_mass));
ANKI_CHECK(xmlF32(rel, "massDeviation", m_particle.m_massDeviation));
ANKI_CHECK(xmlF32(rel, "size", m_particle.m_size));
ANKI_CHECK(xmlF32(rel, "sizeDeviation", m_particle.m_sizeDeviation));
ANKI_CHECK(xmlF32(rel, "sizeAnimation", m_particle.m_sizeAnimation));
ANKI_CHECK(xmlF32(rel, "alpha", m_particle.m_alpha));
ANKI_CHECK(xmlF32(rel, "alphaDeviation", m_particle.m_alphaDeviation));
tmp = m_particle.m_alphaAnimation;
ANKI_CHECK(xmlU32(rel, "alphaAnimationEnabled", tmp));
m_particle.m_alphaAnimation = tmp;
ANKI_CHECK(xmlVec3(rel, "forceDirection", m_particle.m_forceDirection));
ANKI_CHECK(xmlVec3(rel, "forceDirectionDeviation",
m_particle.m_forceDirectionDeviation));
ANKI_CHECK(xmlF32(rel, "forceMagnitude", m_particle.m_forceMagnitude));
ANKI_CHECK(xmlF32(rel, "forceMagnitudeDeviation",
m_particle.m_forceMagnitudeDeviation));
ANKI_CHECK(xmlVec3(rel, "gravity", m_particle.m_gravity));
ANKI_CHECK(xmlVec3(rel, "gravityDeviation", m_particle.m_gravityDeviation));
ANKI_CHECK(xmlVec3(rel, "startingPosition", m_particle.m_startingPos));
ANKI_CHECK(xmlVec3(rel, "startingPositionDeviation",
m_particle.m_startingPosDeviation));
ANKI_CHECK(xmlU32(rel, "maxNumberOfParticles", m_maxNumOfParticles));
ANKI_CHECK(xmlF32(rel, "emissionPeriod", m_emissionPeriod));
ANKI_CHECK(xmlU32(rel, "particlesPerEmittion", m_particlesPerEmittion));
tmp = m_usePhysicsEngine;
ANKI_CHECK(xmlU32(rel, "usePhysicsEngine", tmp));
m_usePhysicsEngine = tmp;
XmlElement el;
CString cstr;
ANKI_CHECK(rel.getChildElement("material", el));
ANKI_CHECK(el.getText(cstr));
ANKI_CHECK(m_material.load(cstr, &getManager()));
// sanity checks
//
static const char* ERROR = "Particle emmiter: "
"Incorrect or missing value %s";
if(m_particle.m_life <= 0.0)
{
ANKI_LOGE(ERROR, "life");
return ErrorCode::USER_DATA;
}
if(m_particle.m_life - m_particle.m_lifeDeviation <= 0.0)
{
ANKI_LOGE(ERROR, "lifeDeviation");
return ErrorCode::USER_DATA;
}
if(m_particle.m_size <= 0.0)
{
ANKI_LOGE(ERROR, "size");
return ErrorCode::USER_DATA;
}
if(m_maxNumOfParticles < 1)
{
ANKI_LOGE(ERROR, "maxNumOfParticles");
return ErrorCode::USER_DATA;
}
if(m_emissionPeriod <= 0.0)
{
ANKI_LOGE(ERROR, "emissionPeriod");
return ErrorCode::USER_DATA;
}
if(m_particlesPerEmittion < 1)
{
ANKI_LOGE(ERROR, "particlesPerEmission");
return ErrorCode::USER_DATA;
}
// Calc some stuff
//.........这里部分代码省略.........
示例13: glitchThreshold
Test::Test(XmlElement *xe,bool &ok, ProductionUnit* unit_) :
input (-1),
output (-1),
num_channels(1),
glitchThreshold(4.0f),
unit(unit_),
requiredTestAdapterProductId(0) // Most tests do not require a specific product ID
{
XmlElement *temp;
temp = xe->getFirstChildElement();
if (temp && temp->isTextElement())
{
title = temp->getText();
title = title.trim();
}
if (application->testManager->getNumLoops())
{
int currentLoop = application->testManager->currentLoop;
if (title.isNotEmpty())
{
title += String::formatted(" - loop %d/%d", currentLoop + 1, application->testManager->getNumLoops());
}
}
getIntValue(xe, "input", input);
getIntValue(xe, "output", output);
getIntValue(xe, "num_channels", num_channels);
ok = getIntValue(xe, "sample_rate_check", sample_rate_check);
if (!ok)
sample_rate_check = 0;
ok = getIntValue(xe, "sample_rate", sample_rate);
ok &= getFloatValue(xe, "output_amplitude_db", output_amplitude_db);
if (sample_rate_check != 0)
{
minSampleRate = sample_rate_check * 0.80f;
maxSampleRate = sample_rate_check * 1.20f;
}
else
{
minSampleRate = sample_rate * 0.94f;
maxSampleRate = sample_rate * 1.06f;
}
getFloatValue(xe, "min_sample_rate", minSampleRate);
getFloatValue(xe, "max_sample_rate", maxSampleRate);
getHexValue(xe, "required_test_adapter_product_id", requiredTestAdapterProductId); // Not required
if (ECHOAIO_INTERFACE_MODULE_REV1 == unit_->getAIORevision())
{
if (minSampleRate > 144000.0)
minSampleRate *= 0.5f;
if (maxSampleRate > 144000.0)
maxSampleRate *= 0.5f;
if (sample_rate > 144000.0)
sample_rate *= 0.5f;
}
output_frequency = 1000.0f;
}
示例14: parseInputsTag
//==============================================================================
void MaterialProgramCreator::parseInputsTag(const XmlElement& programEl)
{
XmlElement inputsEl = programEl.getChildElementOptional("inputs");
if(!inputsEl)
{
return;
}
// Get shader type
GLbitfield glshaderbit;
GLenum glshader;
U shaderidx;
getShaderInfo(
programEl.getChildElement("type").getText(),
glshader, glshaderbit, shaderidx);
XmlElement inputEl = inputsEl.getChildElement("input");
do
{
Input inpvar(m_alloc);
// <name>
inpvar.m_name = inputEl.getChildElement("name").getText();
// <type>
inpvar.m_type = inputEl.getChildElement("type").getText();
// <value>
XmlElement valueEl = inputEl.getChildElement("value");
if(valueEl.getText())
{
inpvar.m_value = MPStringList::splitString(
valueEl.getText(), ' ', m_alloc);
}
// <const>
XmlElement constEl = inputEl.getChildElementOptional("const");
inpvar.m_constant = (constEl) ? constEl.getInt() : false;
// <arraySize>
XmlElement arrSizeEl = inputEl.getChildElementOptional("arraySize");
inpvar.m_arraySize = (arrSizeEl) ? arrSizeEl.getInt() : 0;
// <instanced>
if(inpvar.m_arraySize == 0)
{
XmlElement instancedEl =
inputEl.getChildElementOptional("instanced");
inpvar.m_instanced = (instancedEl) ? instancedEl.getInt() : 0;
// If one input var is instanced notify the whole program that
// it's instanced
if(inpvar.m_instanced)
{
m_instanced = true;
}
}
// Now you have the info to check if duplicate
Input* duplicateInp = nullptr;
for(Input& in : m_inputs)
{
if(in.m_name == inpvar.m_name)
{
duplicateInp = ∈
break;
}
}
if(duplicateInp != nullptr)
{
// Duplicate. Make sure it's the same as the other shader
Bool same = duplicateInp->m_type == inpvar.m_type
|| duplicateInp->m_value == inpvar.m_value
|| duplicateInp->m_constant == inpvar.m_constant
|| duplicateInp->m_arraySize == inpvar.m_arraySize
|| duplicateInp->m_instanced == inpvar.m_instanced;
if(!same)
{
throw ANKI_EXCEPTION("Variable defined differently between "
"shaders: %s", &inpvar.m_name[0]);
}
duplicateInp->m_shaderDefinedMask |= glshaderbit;
goto advance;
}
if(inpvar.m_constant == false)
{
// Handle NON-consts
inpvar.m_line = inpvar.m_type + " " + inpvar.m_name;
if(inpvar.m_arraySize > 1)
{
MPString tmp(MPString::toString(inpvar.m_arraySize, m_alloc));
//.........这里部分代码省略.........
示例15: parseProgramTag
//==============================================================================
void MaterialProgramCreator::parseProgramTag(
const XmlElement& programEl)
{
// <type>
CString type = programEl.getChildElement("type"_cstr).getText();
GLbitfield glshaderbit;
GLenum glshader;
U shaderidx;
getShaderInfo(type, glshader, glshaderbit, shaderidx);
m_source[shaderidx] = MPStringList(m_alloc);
auto& lines = m_source[shaderidx];
lines.push_back(ANKI_STRL("#pragma anki type "_cstr) + type);
if(glshader == GL_TESS_CONTROL_SHADER
|| glshader == GL_TESS_EVALUATION_SHADER)
{
m_tessellation = true;
}
// <includes></includes>
XmlElement includesEl = programEl.getChildElement("includes"_cstr);
XmlElement includeEl = includesEl.getChildElement("include"_cstr);
do
{
MPString fname(includeEl.getText(), m_alloc);
lines.push_back(
ANKI_STRL("#pragma anki include \""_cstr) + fname + "\""_cstr);
includeEl = includeEl.getNextSiblingElement("include"_cstr);
} while(includeEl);
// Inputs
// Block
if(m_uniformBlock.size() > 0
&& (m_uniformBlockReferencedMask | glshaderbit))
{
// TODO Make block SSB when driver bug is fixed
lines.push_back(ANKI_STRL(
"\nlayout(binding = 0, std140) uniform bDefaultBlock\n{"_cstr));
lines.insert(
lines.end(), m_uniformBlock.begin(), m_uniformBlock.end());
lines.push_back(ANKI_STRL("};"));
}
// Other variables
for(Input& in : m_inputs)
{
if(!in.m_inBlock && (in.m_shaderDefinedMask | glshaderbit))
{
lines.push_back(in.m_line);
}
}
// <operations></operations>
lines.push_back(ANKI_STRL("\nvoid main()\n{"));
XmlElement opsEl = programEl.getChildElement("operations");
XmlElement opEl = opsEl.getChildElement("operation");
do
{
MPString out(m_alloc);
parseOperationTag(opEl, glshader, glshaderbit, out);
lines.push_back(out);
// Advance
opEl = opEl.getNextSiblingElement("operation");
} while(opEl);
lines.push_back(ANKI_STRL("}\n"));
}