本文整理汇总了C++中WMLPageState::getVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ WMLPageState::getVariable方法的具体用法?C++ WMLPageState::getVariable怎么用?C++ WMLPageState::getVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMLPageState
的用法示例。
在下文中一共展示了WMLPageState::getVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateDefaultOptionIndices
void WMLSelectElement::calculateDefaultOptionIndices()
{
WMLPageState* pageState = wmlPageStateForDocument(document());
if (!pageState)
return;
String variable;
// Spec: If the 'iname' attribute is specified and names a variable that is set,
// then the default option index is the validated value of that variable.
String iname = this->iname();
if (!iname.isEmpty()) {
variable = pageState->getVariable(iname);
if (!variable.isEmpty())
m_defaultOptionIndices = parseIndexValueString(variable);
}
// Spec: If the default option index is empty and the 'ivalue' attribute is specified,
// then the default option index is the validated attribute value.
String ivalue = this->ivalue();
if (m_defaultOptionIndices.isEmpty() && !ivalue.isEmpty())
m_defaultOptionIndices = parseIndexValueString(ivalue);
// Spec: If the default option index is empty, and the 'name' attribute is specified
// and the 'name' ttribute names a variable that is set, then for each value in the 'name'
// variable that is present as a value in the select's option elements, the index of the
// first option element containing that value is added to the default index if that
// index has not been previously added.
String name = this->name();
if (m_defaultOptionIndices.isEmpty() && !name.isEmpty()) {
variable = pageState->getVariable(name);
if (!variable.isEmpty())
m_defaultOptionIndices = valueStringToOptionIndices(variable);
}
String value = parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
// Spec: If the default option index is empty and the 'value' attribute is specified then
// for each value in the 'value' attribute that is present as a value in the select's
// option elements, the index of the first option element containing that value is added
// to the default index if that index has not been previously added.
if (m_defaultOptionIndices.isEmpty() && !value.isEmpty())
m_defaultOptionIndices = valueStringToOptionIndices(value);
// Spec: If the default option index is empty and the select is a multi-choice, then the
// default option index is set to zero. If the select is single-choice, then the default
// option index is set to one.
if (m_defaultOptionIndices.isEmpty())
m_defaultOptionIndices.append((unsigned) !m_data.multiple());
}
示例2: initialize
void WMLInputElement::initialize()
{
String nameVariable = formControlName();
String variableValue;
WMLPageState* pageSate = wmlPageStateForDocument(document());
ASSERT(pageSate);
if (!nameVariable.isEmpty())
variableValue = pageSate->getVariable(nameVariable);
if (variableValue.isEmpty() || !isConformedToInputMask(variableValue)) {
String val = value();
if (isConformedToInputMask(val))
variableValue = val;
else
variableValue = "";
pageSate->storeVariable(nameVariable, variableValue);
}
setValue(variableValue);
if (!hasAttribute(WMLNames::emptyokAttr)) {
if (m_formatMask.isEmpty() ||
// check if the format codes is just "*f"
(m_formatMask.length() == 2 && m_formatMask[0] == '*' && formatCodes().find(m_formatMask[1]) != notFound))
m_isEmptyOk = true;
}
}
示例3: substituteVariableReferences
String substituteVariableReferences(const String& reference, Document* document, WMLVariableEscapingMode escapeMode)
{
ASSERT(document);
if (reference.isEmpty())
return reference;
WMLPageState* pageState = wmlPageStateForDocument(document);
if (!pageState)
return reference;
bool isValid = true;
String remainingInput = reference;
String result;
while (!remainingInput.isEmpty()) {
ASSERT(isValid);
int start = remainingInput.find("$");
if (start == -1) {
// Consume all remaining characters, as there's nothing more to substitute
result += remainingInput;
break;
}
// Consume all characters until the variable reference beginning
result += remainingInput.left(start);
remainingInput.remove(0, start);
// Transform adjacent dollar signs into a single dollar sign as string literal
if (remainingInput[1] == '$') {
result += "$";
remainingInput.remove(0, 2);
continue;
}
String variableName;
String conversionMode;
if (remainingInput[1] == '(') {
int referenceEndPosition = remainingInput.find(")");
if (referenceEndPosition == -1) {
isValid = false;
break;
}
variableName = remainingInput.substring(2, referenceEndPosition - 2);
remainingInput.remove(0, referenceEndPosition + 1);
// Determine variable conversion mode string
int pos = variableName.find(':');
if (pos != -1) {
conversionMode = variableName.substring(pos + 1, variableName.length() - (pos + 1));
variableName = variableName.left(pos);
}
} else {
int length = remainingInput.length();
int referenceEndPosition = 1;
for (; referenceEndPosition < length; ++referenceEndPosition) {
if (!isValidVariableNameCharacter(remainingInput[referenceEndPosition]))
break;
}
variableName = remainingInput.substring(1, referenceEndPosition - 1);
remainingInput.remove(0, referenceEndPosition);
}
isValid = isValidVariableName(variableName);
if (!isValid)
break;
ASSERT(!variableName.isEmpty());
String variableValue = pageState->getVariable(variableName);
if (variableValue.isEmpty())
continue;
if (containsVariableReference(variableValue, isValid)) {
if (!isValid)
break;
variableValue = substituteVariableReferences(variableValue, document, escapeMode);
continue;
}
if (!conversionMode.isEmpty()) {
// Override default escape mode, if desired
WMLVariableEscapingMode specifiedEscapeMode = WMLVariableEscapingNone;
if ((isValid = isValidVariableEscapingModeString(conversionMode, specifiedEscapeMode)))
escapeMode = specifiedEscapeMode;
if (!isValid)
break;
}
switch (escapeMode) {
case WMLVariableEscapingNone:
break;
case WMLVariableEscapingEscape:
//.........这里部分代码省略.........