本文整理汇总了C++中UString函数的典型用法代码示例。如果您正苦于以下问题:C++ UString函数的具体用法?C++ UString怎么用?C++ UString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
UString UString::from(unsigned u)
{
UChar buf[sizeof(u) * 3];
UChar* end = buf + sizeof(buf) / sizeof(UChar);
UChar* p = end;
if (u == 0)
*--p = '0';
else {
while (u) {
*--p = static_cast<unsigned short>((u % 10) + '0');
u /= 10;
}
}
return UString(p, static_cast<unsigned>(end - p));
}
示例2: while
UString UString::from(unsigned int u)
{
UChar buf[20];
UChar *end = buf + 20;
UChar *p = end;
if (u == 0) {
*--p = '0';
} else {
while (u) {
*--p = (unsigned short)((u % 10) + '0');
u /= 10;
}
}
return UString(p, end - p);
}
示例3: printf
void Profile::debugPrintDataSampleStyle() const
{
typedef Vector<NameCountPair> NameCountPairVector;
FunctionCallHashCount countedFunctions;
printf("Call graph:\n");
m_head->debugPrintDataSampleStyle(0, countedFunctions);
printf("\nTotal number in stack:\n");
NameCountPairVector sortedFunctions(countedFunctions.size());
copyToVector(countedFunctions, sortedFunctions);
std::sort(sortedFunctions.begin(), sortedFunctions.end(), functionNameCountPairComparator);
for (NameCountPairVector::iterator it = sortedFunctions.begin(); it != sortedFunctions.end(); ++it)
printf(" %-12d%s\n", (*it).second, UString((*it).first).UTF8String().c_str());
printf("\nSort by top of stack, same collapsed (when >= 5):\n");
}
示例4: ConvertUInt32ToString
STDMETHODIMP P7ZipArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
{
wchar_t temp[16];
ConvertUInt32ToString(index + 1, temp);
UString res = temp;
while (res.Length() < 2)
res = UString(L'0') + res;
UString fileName = VolName;
fileName += L'.';
fileName += res;
fileName += VolExt;
COutFileStream *streamSpec = new COutFileStream;
CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
if (!streamSpec->Create(fileName, false))
return ::GetLastError();
*volumeStream = streamLoc.Detach();
return S_OK;
}
示例5: size
UString UString::substr(int pos, int len) const
{
int s = size();
if (pos < 0)
pos = 0;
else if (pos >= s)
pos = s;
if (len < 0)
len = s;
if (pos + len >= s)
len = s - pos;
if (pos == 0 && len == s)
return *this;
return UString(Rep::create(m_rep, pos, len));
}
示例6: Stage
UfopaediaCategory::UfopaediaCategory(Framework &fw, tinyxml2::XMLElement* Element) : Stage(fw)
{
UString nodename;
ViewingEntry = 0;
if( Element->Attribute("id") != nullptr && UString(Element->Attribute("id")) != "" )
{
ID = Element->Attribute("id");
}
tinyxml2::XMLElement* node;
for( node = Element->FirstChildElement(); node != nullptr; node = node->NextSiblingElement() )
{
nodename = node->Name();
if( nodename == "backgroundimage" )
{
BackgroundImageFilename = node->GetText();
}
if( nodename == "title" )
{
Title = node->GetText();
}
if( nodename == "text_info" )
{
BodyInformation = node->GetText();
}
if( nodename == "entries" )
{
tinyxml2::XMLElement* node2;
for( node2 = node->FirstChildElement(); node2 != nullptr; node2 = node2->NextSiblingElement() )
{
std::shared_ptr<UfopaediaEntry> newentry = std::make_shared<UfopaediaEntry>( node2 );
Entries.push_back( newentry );
}
}
}
menuform = fw.gamecore->GetForm("FORM_UFOPAEDIA_BASE");
}
示例7: ASSERT
void Debugger::recompileAllJSFunctions(JSGlobalData* globalData)
{
// If JavaScript is running, it's not safe to recompile, since we'll end
// up throwing away code that is live on the stack.
ASSERT(!globalData->dynamicGlobalObject);
if (globalData->dynamicGlobalObject)
return;
typedef HashSet<FunctionExecutable*> FunctionExecutableSet;
typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap;
FunctionExecutableSet functionExecutables;
SourceProviderMap sourceProviders;
LiveObjectIterator it = globalData->heap.primaryHeapBegin();
LiveObjectIterator heapEnd = globalData->heap.primaryHeapEnd();
for ( ; it != heapEnd; ++it) {
if (!(*it)->inherits(&JSFunction::info))
continue;
JSFunction* function = asFunction(*it);
if (function->executable()->isHostFunction())
continue;
FunctionExecutable* executable = function->jsExecutable();
// Check if the function is already in the set - if so,
// we've already retranslated it, nothing to do here.
if (!functionExecutables.add(executable).second)
continue;
ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec();
executable->recompile(exec);
if (function->scope().globalObject()->debugger() == this)
sourceProviders.add(executable->source().provider(), exec);
}
// Call sourceParsed() after reparsing all functions because it will execute
// JavaScript in the inspector.
SourceProviderMap::const_iterator end = sourceProviders.end();
for (SourceProviderMap::const_iterator iter = sourceProviders.begin(); iter != end; ++iter)
sourceParsed(iter->second, SourceCode(iter->first), -1, UString());
}
示例8: newExec
JSValue* DebuggerCallFrame::evaluate(const UString& script, JSValue*& exception) const
{
if (!m_codeBlock)
return 0;
JSObject* thisObject = this->thisObject();
ExecState newExec(m_scopeChain->globalObject(), thisObject, m_scopeChain);
int sourceId;
int errLine;
UString errMsg;
RefPtr<SourceProvider> sourceProvider = UStringSourceProvider::create(script);
RefPtr<EvalNode> evalNode = newExec.parser()->parse<EvalNode>(&newExec, UString(), 1, sourceProvider, &sourceId, &errLine, &errMsg);
if (!evalNode)
return Error::create(&newExec, SyntaxError, errMsg, errLine, sourceId, 0);
return newExec.machine()->execute(evalNode.get(), &newExec, thisObject, m_scopeChain, &exception);
}
示例9: ConvertPropVariantToString
UString ConvertPropVariantToString(const PROPVARIANT &prop)
{
switch (prop.vt)
{
case VT_EMPTY: return UString();
case VT_BSTR: return prop.bstrVal;
case VT_UI1: return ConvertUInt64ToString(prop.bVal);
case VT_UI2: return ConvertUInt64ToString(prop.uiVal);
case VT_UI4: return ConvertUInt64ToString(prop.ulVal);
case VT_UI8: return ConvertUInt64ToString(prop.uhVal.QuadPart);
case VT_FILETIME: return ConvertFileTimeToString(prop.filetime, true, true);
// case VT_I1: return ConvertInt64ToString(prop.cVal);
case VT_I2: return ConvertInt64ToString(prop.iVal);
case VT_I4: return ConvertInt64ToString(prop.lVal);
case VT_I8: return ConvertInt64ToString(prop.hVal.QuadPart);
case VT_BOOL: return VARIANT_BOOLToBool(prop.boolVal) ? L"+" : L"-";
default: throw 150245;
}
}
示例10: IsValidLocation
void mtstring::atlocation(const double& rX,
const double& rY,
MString& rValues) const
{
rValues.SetDefined(false);
if(IsDefined() &&
IsValidLocation(rX, rY))
{
rValues.SetDefined(true);
Rectangle<3> boundingBox;
bbox(boundingBox);
Instant minimumTime = boundingBox.MinD(2);
Instant maximumTime = boundingBox.MaxD(2);
datetime::DateTime duration = m_Grid.GetDuration();
rValues.StartBulkLoad();
for(Instant currentTime = minimumTime;
currentTime < maximumTime;
currentTime += duration)
{
CcString value;
atlocation(rX, rY, currentTime.ToDouble(), value);
if(value.IsDefined())
{
Interval<Instant> interval(currentTime, currentTime + duration,
true, false);
rValues.Add(UString(interval, value, value));
}
}
rValues.EndBulkLoad();
if(rValues.IsEmpty())
{
rValues.SetDefined(false);
}
}
}
示例11: minPlain
//------------------------------------------------------------------------
RangeParameter::RangeParameter (const TChar* title, ParamID tag, const TChar* units,
ParamValue minPlain, ParamValue maxPlain, ParamValue defaultValuePlain,
int32 stepCount, int32 flags, UnitID unitID)
: minPlain (minPlain)
, maxPlain (maxPlain)
{
UString (info.title, tStrBufferSize(String128)).assign (title);
UString uUnits (info.units, tStrBufferSize(String128));
if (units)
{
uUnits.assign (units);
}
info.stepCount = stepCount;
info.defaultNormalizedValue = toNormalized (defaultValuePlain);
info.flags = flags;
info.id = tag;
info.unitId = unitID;
}
示例12: regExpProtoFuncCompile
EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&RegExpObject::s_info))
return throwVMTypeError(exec);
RegExp* regExp;
JSValue arg0 = exec->argument(0);
JSValue arg1 = exec->argument(1);
if (arg0.isSymbolic() || arg1.isSymbolic()) {
Statistics::statistics()->accumulate("Concolic::MissingInstrumentation::regExpProtoFuncCompile", 1);
}
if (arg0.inherits(&RegExpObject::s_info)) {
if (!arg1.isUndefined())
return throwVMError(exec, createTypeError(exec, "Cannot supply flags when constructing one RegExp from another."));
regExp = asRegExpObject(arg0)->regExp();
} else {
UString pattern = !exec->argumentCount() ? UString("") : arg0.toString(exec)->value(exec);
if (exec->hadException())
return JSValue::encode(jsUndefined());
RegExpFlags flags = NoFlags;
if (!arg1.isUndefined()) {
flags = regExpFlags(arg1.toString(exec)->value(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
if (flags == InvalidFlags)
return throwVMError(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
}
regExp = RegExp::create(exec->globalData(), pattern, flags);
}
if (!regExp->isValid())
return throwVMError(exec, createSyntaxError(exec, regExp->errorMessage()));
asRegExpObject(thisValue)->setRegExp(exec->globalData(), regExp);
asRegExpObject(thisValue)->setLastIndex(exec, 0);
return JSValue::encode(jsUndefined());
}
示例13: parseFrame
static bool parseFrame(tinyxml2::XMLElement *root, DoodadFrame &f)
{
if (UString(root->Name()) != "frame")
{
LogError("Called on unexpected node \"%s\"", root->Name());
return false;
}
if (!ReadAttribute(root, "time", f.time))
{
LogError("No \"time\" attribute in frame");
return false;
}
UString spritePath = root->GetText();
f.image = fw().data->load_image(spritePath);
if (!f.image)
{
LogError("Failed to load sprite \"%s\" for doodad frame", spritePath.c_str());
return false;
}
return true;
}
示例14: al_get_ustr_width
void TextEntry::maybe_scroll()
{
const Theme & theme = dialog->get_theme();
if (cursor_pos < left_pos + 3) {
if (cursor_pos < 3)
left_pos = 0;
else
left_pos = cursor_pos - 3;
}
else {
for (;;) {
const int tw = al_get_ustr_width(theme.font,
UString(text, left_pos, cursor_pos));
if (x1 + tw + CURSOR_WIDTH < x2) {
break;
}
al_ustr_next(text, &left_pos);
}
}
}
示例15: stringProtoFuncToLocaleUpperCase
JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
JSString* sVal = thisValue->toThisJSString(exec);
const UString& s = sVal->value();
int ssize = s.size();
if (!ssize)
return sVal;
Vector<UChar> buffer(ssize);
bool error;
int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error);
if (error) {
buffer.resize(length);
length = Unicode::toUpper(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error);
if (error)
return sVal;
}
if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0)
return sVal;
return jsString(exec, UString(buffer.releaseBuffer(), length, false));
}