本文整理汇总了C++中LLString::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ LLString::substr方法的具体用法?C++ LLString::substr怎么用?C++ LLString::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLString
的用法示例。
在下文中一共展示了LLString::substr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
// Reads a .tga file and creates an LLImageTGA with its data.
bool LLImageTGA::loadFile( const LLString& path )
{
S32 len = path.size();
if( len < 5 )
{
return false;
}
LLString extension = path.substr( len - 4, 4 );
LLString::toLower(extension);
if( ".tga" != extension )
{
return false;
}
FILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */
if( !file )
{
llwarns << "Couldn't open file " << path << llendl;
return false;
}
S32 file_size = 0;
if (!fseek(file, 0, SEEK_END))
{
file_size = ftell(file);
fseek(file, 0, SEEK_SET);
}
U8* buffer = allocateData(file_size);
S32 bytes_read = fread(buffer, 1, file_size, file);
if( bytes_read != file_size )
{
deleteData();
llwarns << "Couldn't read file " << path << llendl;
return false;
}
fclose( file );
if( !updateData() )
{
llwarns << "Couldn't decode file " << path << llendl;
deleteData();
return false;
}
return true;
}
示例2: process_secondlife_url
BOOL process_secondlife_url(LLString url)
{
S32 strpos, strpos2;
LLString slurlID = "slurl.com/secondlife/";
strpos = url.find(slurlID);
if (strpos < 0)
{
slurlID="secondlife://";
strpos = url.find(slurlID);
}
if (strpos >= 0)
{
LLString simname;
strpos+=slurlID.length();
strpos2=url.find("/",strpos);
if (strpos2 < strpos) strpos2=url.length();
simname="secondlife://" + url.substr(strpos,url.length() - strpos);
LLURLSimString::setString( simname );
LLURLSimString::parse();
// if there is a world map
if ( gFloaterWorldMap )
{
// mark where the destination is
gFloaterWorldMap->trackURL( LLURLSimString::sInstance.mSimName.c_str(),
LLURLSimString::sInstance.mX,
LLURLSimString::sInstance.mY,
LLURLSimString::sInstance.mZ );
// display map
LLFloaterWorldMap::show( NULL, TRUE );
};
return TRUE;
}
return FALSE;
}
示例3: loadFromFileLegacy
U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_declaration, eControlType declare_as)
{
U32 item = 0;
U32 validitems = 0;
llifstream file;
S32 version;
file.open(filename.c_str()); /*Flawfinder: ignore*/
if (!file)
{
llinfos << "LLControlGroup::loadFromFile unable to open." << llendl;
return 0;
}
// Check file version
LLString name;
file >> name;
file >> version;
if (name != "version" || version != CURRENT_VERSION)
{
llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl;
return 0;
}
while (!file.eof())
{
file >> name;
if (name.empty())
{
continue;
}
if (name.substr(0,2) == "//")
{
// This is a comment.
char buffer[MAX_STRING]; /*Flawfinder: ignore*/
file.getline(buffer, MAX_STRING);
continue;
}
BOOL declared = mNameTable.find(name) != mNameTable.end();
if (require_declaration && !declared)
{
// Declaration required, but this name not declared.
// Complain about non-empty names.
if (!name.empty())
{
//read in to end of line
char buffer[MAX_STRING]; /*Flawfinder: ignore*/
file.getline(buffer, MAX_STRING);
llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl;
}
continue;
}
// Got an item. Load it up.
item++;
// If not declared, assume it's a string
if (!declared)
{
switch(declare_as)
{
case TYPE_COL4:
declareColor4(name, LLColor4::white, LLString::null, NO_PERSIST);
break;
case TYPE_COL4U:
declareColor4U(name, LLColor4U::white, LLString::null, NO_PERSIST);
break;
case TYPE_STRING:
default:
declareString(name, LLString::null, LLString::null, NO_PERSIST);
break;
}
}
// Control name has been declared in code.
LLControlBase *control = getControl(name);
llassert(control);
mLoadedSettings.insert(name);
switch(control->mType)
{
case TYPE_F32:
{
F32 initial;
file >> initial;
control->set(initial);
validitems++;
}
break;
case TYPE_S32:
{
//.........这里部分代码省略.........
示例4: upload_new_resource
void upload_new_resource(const LLString& src_filename, std::string name,
std::string desc, S32 compression_info,
LLAssetType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perm,
const LLString& display_name,
LLAssetStorage::LLStoreAssetCallback callback,
void *userdata)
{
// Generate the temporary UUID.
LLString filename = gDirUtilp->getTempFilename();
LLTransactionID tid;
LLAssetID uuid;
LLStringBase<char>::format_map_t args;
LLString ext = src_filename.substr(src_filename.find_last_of('.'));
LLAssetType::EType asset_type = LLAssetType::AT_NONE;
char error_message[MAX_STRING]; /* Flawfinder: ignore */
error_message[0] = '\0';
LLString temp_str;
BOOL error = FALSE;
if (ext.empty())
{
LLString::size_type offset = filename.find_last_of(gDirUtilp->getDirDelimiter());
if (offset != LLString::npos)
offset++;
LLString short_name = filename.substr(offset);
// No extension
snprintf(error_message, /* Flawfinder: ignore */
MAX_STRING,
"No file extension for the file: '%s'\nPlease make sure the file has a correct file extension",
short_name.c_str());
args["[FILE]"] = short_name;
upload_error(error_message, "NofileExtension", filename, args);
return;
}
else if( LLString::compareInsensitive(ext.c_str(),".bmp") == 0 )
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerImageList::createUploadFile(src_filename,
filename,
IMG_CODEC_BMP ))
{
snprintf(error_message, MAX_STRING, "Problem with file %s:\n\n%s\n", /* Flawfinder: ignore */
src_filename.c_str(), LLImageBase::getLastError().c_str());
args["[FILE]"] = src_filename;
args["[ERROR]"] = LLImageBase::getLastError();
upload_error(error_message, "ProblemWithFile", filename, args);
return;
}
}
else if( LLString::compareInsensitive(ext.c_str(),".tga") == 0 )
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerImageList::createUploadFile(src_filename,
filename,
IMG_CODEC_TGA ))
{
snprintf(error_message, MAX_STRING, "Problem with file %s:\n\n%s\n", /* Flawfinder: ignore */
src_filename.c_str(), LLImageBase::getLastError().c_str());
args["[FILE]"] = src_filename;
args["[ERROR]"] = LLImageBase::getLastError();
upload_error(error_message, "ProblemWithFile", filename, args);
return;
}
}
else if( LLString::compareInsensitive(ext.c_str(),".jpg") == 0 || LLString::compareInsensitive(ext.c_str(),".jpeg") == 0)
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerImageList::createUploadFile(src_filename,
filename,
IMG_CODEC_JPEG ))
{
snprintf(error_message, MAX_STRING, "Problem with file %s:\n\n%s\n", /* Flawfinder: ignore */
src_filename.c_str(), LLImageBase::getLastError().c_str());
args["[FILE]"] = src_filename;
args["[ERROR]"] = LLImageBase::getLastError();
upload_error(error_message, "ProblemWithFile", filename, args);
return;
}
}
else if(LLString::compareInsensitive(ext.c_str(),".wav") == 0)
{
asset_type = LLAssetType::AT_SOUND; // tag it as audio
S32 encode_result = 0;
S32 bitrate = 128;
if (compression_info)
{
bitrate = compression_info;
}
llinfos << "Attempting to encode wav as an ogg file at " << bitrate << "kbps" << llendl;
encode_result = encode_vorbis_file_at(src_filename.c_str(), filename.c_str(), bitrate*1000);
//.........这里部分代码省略.........