void VJSImage::_save(XBOX::VJSParms_callStaticFunction& ioParms, VJSPictureContainer* inPict) { VPictureCodecFactoryRef fact; const VPictureCodec* encoder = nil; bool ok = false; VPicture* pic = inPict->GetPict(); if (pic != nil) { VFile* file = ioParms.RetainFileParam(1); if (file != nil) { VString mimetype; ioParms.GetStringParam(2, mimetype); if (mimetype.IsEmpty()) { VString extension; file->GetExtension(extension); if (extension.IsEmpty()) extension = L"pic"; encoder = fact->RetainEncoderForExtension(extension); } else encoder = fact->RetainEncoderByIdentifier(mimetype); if (encoder != nil) { VError err = VE_OK; if (file->Exists()) err = file->Delete(); if (err == VE_OK) { VValueBag *pictureSettings = nil; VValueBag *bagMetas = (VValueBag*)inPict->RetainMetaBag(); if (bagMetas != nil) { pictureSettings = new VValueBag(); ImageEncoding::stWriter settingsWriter(pictureSettings); VValueBag *bagRetained = settingsWriter.CreateOrRetainMetadatas( bagMetas); if (bagRetained) bagRetained->Release(); } err=encoder->Encode(*pic, pictureSettings, *file); QuickReleaseRefCountable(bagMetas); QuickReleaseRefCountable(pictureSettings); if (err == VE_OK) ok = true; } encoder->Release(); } file->Release(); } else vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_FILE, "1"); } ioParms.ReturnBool(ok); }
VNetAddress::VNetAddress(const VString& inIp, PortNumber inPort) { xbox_assert(!inIp.IsEmpty()); if(inIp.IsEmpty()) vThrowError(fNetAddr.FromIpAndPort(GetAnyIP(), inPort)); else vThrowError(fNetAddr.FromIpAndPort(inIp, inPort)); }
VString XLinuxIntlMgr::GetDateSeparator() const { VString dateSeparator; icu::DateFormat* dateFmt=icu::DateFormat::createDateInstance(icu::DateFormat::SHORT, fLocale); xbox_assert(dateFmt!=NULL); icu::SimpleDateFormat* simpleDateFmt=reinterpret_cast<icu::SimpleDateFormat*>(dateFmt); xbox_assert(simpleDateFmt!=NULL); if(simpleDateFmt!=NULL) { UErrorCode err=U_ZERO_ERROR; UnicodeString tmpPattern; simpleDateFmt->toLocalizedPattern(tmpPattern, err); xbox_assert(err==U_ZERO_ERROR); VString datePattern(tmpPattern.getTerminatedBuffer()); bool isQuoted=false; for(int i=0 ; i<datePattern.GetLength() ; i++) { UniChar c=datePattern[i]; if(c=='\'') isQuoted=!isQuoted; if(isQuoted) continue; //ICU works with patterns ("M/d/yy" for ex.) and doesn't have a notion of date separator. //As a work around, we try to get a localized date pattern and pick the first char that looks like a separator. if(!(c>='A' && c<='Z') && !(c>='a' && c<='z')) { dateSeparator.AppendUniChar(c); break; } } } if(dateFmt!=NULL) delete dateFmt; xbox_assert(!dateSeparator.IsEmpty()); if(dateSeparator.IsEmpty()) return VString("/"); return dateSeparator; }
void RPG_Projectile::SetProjectileMesh(VString const& meshFilename) { if (!meshFilename.IsEmpty()) { m_projectileMeshFilename = meshFilename; } }
VString XLinuxIntlMgr::GetTimeSeparator() const { VString timeSeparator; VString timePattern=GetDateOrTimePattern(SHORT_TIME); bool isQuoted=false; for(int i=0 ; i<timePattern.GetLength() ; i++) { UniChar c=timePattern[i]; if(c=='\'') isQuoted=!isQuoted; if(isQuoted) continue; if(!(c>='A' && c<='Z') && !(c>='a' && c<='z')) { timeSeparator.AppendUniChar(c); break; } } if(timeSeparator.IsEmpty()) return VString(":"); return timeSeparator; }
bool VFontMetrics::MousePosToTextPos(const VString& inString, GReal inMousePos, sLONG& ioTextPos, GReal& ioPixPos) { if (inString.IsEmpty()) return false; return fMetrics.MousePosToTextPos( inString, inMousePos, ioTextPos, ioPixPos); }
VFile* XLinuxLibrary::RetainExecutableFile(const VFilePath &inFilePath) const { //jmo - What are we supposed to retain ? First we try the exact path... if(inFilePath.IsFile()) return new VFile(inFilePath); //jmo - If exact path doesn't work, we assume inFilePath to be part of a bundle // and try to find the corresponding shared object. VFilePath bundlePath=inFilePath; while(!bundlePath.MatchExtension(CVSTR("bundle"), true /*case sensitive*/) && bundlePath.IsValid()) bundlePath=bundlePath.ToParent(); if(!bundlePath.IsValid()) return NULL; VString name; bundlePath.GetFolderName(name, false /*no ext.*/); if(name.IsEmpty()) return NULL; VString soSubPath=CVSTR("Contents/Linux/")+VString(name)+CVSTR(".so"); VFilePath soPath; soPath.FromRelativePath(bundlePath, soSubPath, FPS_POSIX); if(soPath.IsFile()) return new VFile(soPath); return NULL; }
bool VJSONSingleObjectWriter::AddMember( const VString& inName, const VValueSingle &inValue, JSONOption inModifier) { bool ok = false; VString valueString; if(testAssert(inValue.GetJSONString( valueString, inModifier) == VE_OK) && !inName.IsEmpty()) { if (fIsClosed) { fObject.Remove( fObject.GetLength(), 1); fIsClosed = false; } if (fMembersCount > 0) fObject.AppendUniChar( ','); fObject.AppendUniChar( '"'); fObject.AppendString( inName); fObject.AppendUniChar( '"'); fObject.AppendUniChar( ':'); fObject.AppendString( valueString); ++fMembersCount; ok = true; } return ok; }
void VLocalizationGroupHandler::SetAttribute(const VString& inName, const VString& inValue) { if (fGroupBag == NULL) fGroupBag = new VValueBag; if (inName.EqualToUSASCIICString( "id")) { sLONG idValue = inValue.GetLong(); if (idValue != 0) fGroupID = idValue; //else //DebugMsg( "VLocalizationGroupHandler::Non-valid group id Value : %S\n", &inValue); } else if (inName.EqualToUSASCIICString( "resname")) { if (!inValue.IsEmpty()) { fGroupResnamesStack.top() = inValue; } } else if (inName.EqualToUSASCIICString( "restype")) { xbox_assert( fGroupRestype.IsEmpty() ); // no nested group fGroupRestype = inValue; } if (fGroupBag != NULL) fGroupBag->SetAttribute( inName, inValue); }
// [static] VError XMacSystem::GetProcessorBrandName( XBOX::VString& outProcessorName) { VError error = VE_OK; static VString sProcessorName; if (sProcessorName.IsEmpty()) { // machdep.cpu.brand_string n'est dispo que sur intel char buffer[512]; size_t size = sizeof( buffer); int r = ::sysctlbyname( "machdep.cpu.brand_string", buffer, &size, NULL, 0); if (testAssert( r == 0)) { sProcessorName.FromBlock( buffer, size, VTC_UTF_8); } else { error = VE_UNKNOWN_ERROR; } } outProcessorName = sProcessorName; return error; }
VRTLSupport_cl::VRTLSupport_cl(VisFont_cl * pFont, const VString & utf8Text) : m_pFont(pFont), m_ppTextLines(NULL), m_iTextLines(0) { VASSERT(pFont != NULL); //set the text to display (if present) if(!utf8Text.IsEmpty()) SetText(utf8Text); }
void RPG_Attachment::Attach(VisObject3D_cl* object, const VString& boneName, const hkvVec3& positionOffset /*= hkvVec3(0.f, 0.f, 0.f)*/, const hkvVec3& orientationOffset /*= hkvVec3(0.f, 0.f, 0.f)*/) { if(!m_parent || !object) { return; } m_object = object; m_boneName = boneName; m_positionOffset = positionOffset; m_orientationOffset = orientationOffset; bool validBone = false; if(!boneName.IsEmpty()) { if(m_parent->GetMesh()->GetSkeleton()->GetBoneIndexByName(m_boneName) != -1) { validBone = true; } else { Vision::Error.Warning("RPG_Attachment::Attach - Supplied bone name doesn't exist on this skeleton: %s", boneName.AsChar()); } } if(validBone) { // attach the proxy to the parent bone if specified if (!m_proxy) { // @note: m_proxy is not deleted within this class, because the attachment parent deletes it m_proxy = new VSkeletalBoneProxyObject(); } m_proxy->AttachToEntityBone(m_parent, m_boneName.AsChar()); m_proxy->UpdateBoneBinding(); // attach the new object to the proxy m_object->AttachToParent(m_proxy); VASSERT(m_proxy->GetParent() == m_parent); VASSERT(m_object->GetParent() == m_proxy); } else { // if no bone is specified, just attach to the parent object m_object->AttachToParent(m_parent); VASSERT(m_object->GetParent() == m_parent); } m_object->ResetLocalTransformation(); m_object->SetLocalPosition(m_positionOffset); m_object->SetLocalOrientation(m_orientationOffset); }
void VJSGlobalClass::do_SetCurrentUser( VJSParms_callStaticFunction& inParms, VJSGlobalObject*) { VString username; inParms.GetStringParam(1, username); if (!username.IsEmpty()) { // a faire ici ou dans VJSSolution ? } }
void VEnvironmentVariables::RemoveEnvironmentVariable(const VString &inEnvName) { if(!inEnvName.IsEmpty() && !fEnvVars.empty()) { EnvVarNamesAndValuesMap::iterator envVarIt = fEnvVars.find(inEnvName); if(envVarIt != fEnvVars.end()) fEnvVars.erase(envVarIt); } }
bool VJSValue::GetURL( XBOX::VURL& outURL, JS4D::ExceptionRef *outException) const { VString path; if (!GetString( path, outException) && !path.IsEmpty()) return false; JS4D::GetURLFromPath( path, outURL); return true; }
VArabicSupport_cl::VArabicSupport_cl(VisFont_cl * pArabicFont, const VString & utf8ArabicText, bool isContextualArabic, bool duplicateSpacesDuringConversion) : VRTLSupport_cl() { VASSERT(pArabicFont != NULL); m_pFont = pArabicFont; //set the text to display (if present) if(!utf8ArabicText.IsEmpty()) SetText(utf8ArabicText, isContextualArabic, duplicateSpacesDuringConversion); }
void VValueBag::DumpXMLCData( VString& ioDump, VIndex inCDataAttributeIndex) const { VStr<1000> cdata; GetNthAttribute( inCDataAttributeIndex, NULL)->GetString( cdata); if (NeedsEscapeSequence( cdata, sXMLEscapeChars_Contents, sXMLEscapeChars_Contents + sizeof(sXMLEscapeChars_Contents)/sizeof(UniChar))) { ioDump += CVSTR( "<![CDATA["); // see if there's a "]]>" for which we need to split // someting like: hello ]]> world // becomes: <![CDATA[hello ]]>]]<![CDATA[> world]]> VIndex pos = 1; while( pos <= cdata.GetLength()) { VIndex endTag = cdata.Find( CVSTR( "]]>"), pos, true); if (endTag > 0) { // add everything including ]]> ioDump.AppendBlock( cdata.GetCPointer() + pos - 1, (endTag - pos + 3) * sizeof( UniChar), VTC_UTF_16); // add ]] outside CDATA section ioDump.AppendString( CVSTR( "]]")); // open a new CDATA section and add remaining > ioDump += CVSTR( "<![CDATA[>"); pos = endTag + 3; } else { // add everything left ioDump.AppendBlock( cdata.GetCPointer() + pos - 1, (cdata.GetLength() - pos + 1) * sizeof( UniChar), VTC_UTF_16); break; } } ioDump += CVSTR( "]]>"); } else { VString toInsert; for (sLONG i = 0, n = cdata.GetLength(); i < n; i++) { UniChar c = cdata[ i ]; if (c != 13 && c != 10 && c != 9) { toInsert += c; } } if ( ! toInsert.IsEmpty() ) ioDump += toInsert; } }
void XWinProcessLauncher::SetDefaultDirectory(const VString &inDirectory) { delete [] fCurrentDirectory; fCurrentDirectory = NULL; if(!inDirectory.IsEmpty()) { VFolder theFolder(inDirectory); VString currentDirectoryPath = theFolder.GetPath().GetPath(); fCurrentDirectory = _CreateCString(currentDirectoryPath, true); } }
bool RPG_VisionEffectHelper::PlaySoundFile(VString const& sfxFilename, hkvVec3 const& position /*= hkvVec3(0.f, 0.f, 0.f)*/) { VASSERT(!sfxFilename.IsEmpty()); RPG_VisionEffectSoundParams soundParams; { soundParams.m_soundFilename = sfxFilename.AsChar(); soundParams.m_position = position; if (RPG_VisionEffectHelper::CreateSoundEffect(soundParams)) { return true; } } return false; }
void XPosixProcessLauncher::CreateArgumentsFromFullCommandLine(const VString &inFullCommandLine) { fArrayArg.clear(); if(!inFullCommandLine.IsEmpty()) { char *commandLineCStr = _CreateCString(inFullCommandLine); sLONG argCount = _AnalyzeCommandLine(commandLineCStr, &fArrayArg); if(argCount > 0) SetBinaryPath(fArrayArg[0]); delete [] commandLineCStr; } }
static bool PutStringIntoDictionary( const VString& inString, CFMutableDictionaryRef inDictionary, CFStringRef inDictionaryKey) { bool ok = false; if (!inString.IsEmpty() && (inDictionary != NULL) ) { CFStringRef cfString = inString.MAC_RetainCFStringCopy(); if (cfString != NULL) { CFDictionaryAddValue( inDictionary, inDictionaryKey, cfString); CFRelease( cfString); ok = true; } } return ok; }
void LightmapManager::SaveLightGrid() { VLightGrid_cl *pGrid = Vision::RenderLoopHelper.GetLightGrid(); if (!pLightGridInfo || !pGrid) return; pLightGridInfo->MixAndUpdate(pGrid); VString sAbsFilename; const char *szFilename = pGrid->GetFilename(); String ^absPath = EditorManager::EngineManager->File_MakeAbsolute(ConversionUtils::VStringToString(szFilename)); ConversionUtils::StringToVString( absPath, sAbsFilename ); if (sAbsFilename.IsEmpty()) return; pGrid->SaveToFile(sAbsFilename, szFilename); }
bool JS4D::GetURLFromPath( const VString& inPath, XBOX::VURL& outURL) { VIndex index = inPath.FindRawString( CVSTR( "://")); if (index > 0)//URL { outURL.FromString( inPath, true); } else if (!inPath.IsEmpty()) //system path { outURL.FromFilePath( inPath, eURL_POSIX_STYLE); } else { outURL.Clear(); } return outURL.IsConformRFC(); }
bool VEnvironmentVariables::GetEnvironmentVariableValue(const VString &inEnvName, VString &outEnvValue, bool inAndRemoveIt) { bool gotIt = false; outEnvValue.Clear(); if(!inEnvName.IsEmpty() && !fEnvVars.empty()) { EnvVarNamesAndValuesMap::iterator envVarIt = fEnvVars.find(inEnvName); if(envVarIt != fEnvVars.end()) { outEnvValue = envVarIt->second; gotIt = true; if(inAndRemoveIt) fEnvVars.erase(envVarIt); } } return gotIt; }
void XWinProcessLauncher::SetBinaryPath(const VString &inBinaryPath) { delete [] fBinaryPath; fBinaryPath = NULL; // ACI0065260 - 2010-03-11, T.A. // Add quotes if the path contains a space and is not already quoted if( !inBinaryPath.IsEmpty() && inBinaryPath.FindUniChar(CHAR_SPACE) > 0 && inBinaryPath[0] != CHAR_QUOTATION_MARK ) { VString quotedPath; quotedPath = CHAR_QUOTATION_MARK; quotedPath += inBinaryPath; quotedPath += CHAR_QUOTATION_MARK; fBinaryPath = _CreateCString(quotedPath); } else { fBinaryPath = _CreateCString(inBinaryPath); } }
void VJSGlobalClass::do_SyncEvent(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*) { VString s; bool okresult = false; if (ioParms.IsStringParam(1)) { ioParms.GetStringParam(1, s); if (!s.IsEmpty()) { jsSyncEvent* sync = jsSyncEvent::RetainSyncEvent(s); if (sync != nil) { okresult = true; ioParms.ReturnValue(VJSSyncEvent::CreateInstance(ioParms.GetContextRef(), sync)); sync->Release(); } } } else vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1"); if (!okresult) ioParms.ReturnNullValue(); }
VSysLogOutput::VSysLogOutput( const VString& inIdentifier) : fFilter((1<<EML_Trace) | (1<<EML_Information) | (1<<EML_Warning) | (1<<EML_Error) | (1<<EML_Fatal)) , fIdentifier( NULL) { if (!inIdentifier.IsEmpty()) { // SysLog retain the identifier buffer pointer until closelog() is called StStringConverter<char> converter( inIdentifier, VTC_StdLib_char); if (converter.GetSize() > 0) { fIdentifier = VMemory::NewPtrClear( converter.GetSize() + 1, 'SYSL'); if (fIdentifier != NULL) { VMemory::CopyBlock( converter.GetCPointer(), fIdentifier, converter.GetSize()); } } } // the facility may have to be changed according to the context (user process, daemon...) openlog( fIdentifier, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); }
void LightmapPageTweakInfo::Save(UBYTE *pDestBuffer) { for (int i=0;i<4;i++) { if (!MixSingleChannel(i,pDestBuffer,true)) continue; int iSizeX = m_spLightmapChannel[i]->GetTextureWidth(); int iSizeY = m_spLightmapChannel[i]->GetTextureHeight(); // use vtex to save dds texture Image_cl image; VString sAbsFilename; const char *szFilename = m_spLightmapChannel[i]->GetFilename(); String ^absPath = EditorManager::EngineManager->File_MakeAbsolute(ConversionUtils::VStringToString(szFilename)); ConversionUtils::StringToVString( absPath, sAbsFilename ); if (sAbsFilename.IsEmpty()) continue; image.AddColorMap( iSizeX, iSizeY, COLORDEPTH_24BPP, (UBYTE *) pDestBuffer ); image.Save(sAbsFilename); } }
void VJSImage::_setPath(XBOX::VJSParms_callStaticFunction& ioParms, VJSPictureContainer* inPict) { VPicture* pic = inPict->GetPict(); VString path; if (pic != nil) { if (ioParms.CountParams() == 0 || ioParms.IsNullParam(1)) { pic->SetOutsidePath(""); // empty string means no outside } else if (ioParms.IsBooleanParam(1)) { pic->SetOutsidePath("*"); } else if (ioParms.IsStringParam(1)) { ioParms.GetStringParam(1, path); pic->SetOutsidePath(path); if (!path.IsEmpty()) pic->ReloadFromOutsidePath(); } else { VFile* file = ioParms.RetainFileParam(1); if (file != nil) { file->GetPath(path, FPS_POSIX); pic->SetOutsidePath(path); if (file->Exists()) pic->ReloadFromOutsidePath(); } else pic->SetOutsidePath(""); QuickReleaseRefCountable(file); } //inPict->SetModif(); } }
void VJSGlobalClass::do_AtomicSection(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*) { VString s; bool okresult = false; if (ioParms.IsStringParam(1)) { ioParms.GetStringParam(1, s); if (!s.IsEmpty()) { jsAtomicSection* atomsec = jsAtomicSection::RetainAtomicSection(s); if (atomsec != nil) { okresult = true; ioParms.ReturnValue(VJSAtomicSection::CreateInstance(ioParms.GetContextRef(), atomsec)); atomsec->Release(); } } } else vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1"); if (!okresult) ioParms.ReturnNullValue(); }