本文整理汇总了C++中std::string::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ string::assign方法的具体用法?C++ string::assign怎么用?C++ string::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getInfo
bool TaskRecorderManagerClient::getInfo(const task_recorder2_msgs::Description& description,
std::string& abs_file_name)
{
if(!servicesAreReady())
{
waitForServices();
}
task_recorder2::GetInfo::Request get_info_request;
get_info_request.description = description;
task_recorder2::GetInfo::Response get_info_response;
if(!get_info_service_client_.call(get_info_request, get_info_response))
{
ROS_ERROR("Problems when calling >%s<.", get_info_service_client_.getService().c_str());
return false;
}
if(get_info_response.return_code != task_recorder2::GetInfo::Response::SERVICE_CALL_SUCCESSFUL)
{
ROS_ERROR("Service >%s< was not successful: %s (%i)", get_info_service_client_.getService().c_str(),
get_info_response.info.c_str(), get_info_response.return_code);
return false;
}
abs_file_name.assign(get_info_response.file_name);
return true;
}
示例2: xml_decode
static void xml_decode(const char *str, std::string& decoded)
{
static const char raw_entrs[] = {
'<', '>', '&', '\'', '\"', 0
};
static const char* xml_entrs[] = {
"lt;", "gt;", "amp;", "apos;", "quot;", 0
};
static const int xml_ent_len[] = {
3, 3, 4, 5, 5
};
int ient;
const char *amp = strchr(str, '&');
if (amp == NULL) {
decoded = str;
return;
}
decoded.assign(str, amp - str);
while (*amp)
if (*amp == '&') {
for (ient = 0; xml_entrs[ient] != 0; ++ient)
if (strncmp(amp + 1, xml_entrs[ient],
xml_ent_len[ient]) == 0) {
decoded += raw_entrs[ient];
amp += xml_ent_len[ient]+1;
break;
}
if (xml_entrs[ient] == 0) // unrecognized sequence
decoded += *amp++;
} else {
decoded += *amp++;
}
}
示例3: switch
void
Compressor::compress(std::string & in, std::string & out)
{
switch (m_compression_codec) {
case CompressionCodec::UNCOMPRESSED:
{
// Just swap the input and output collections ...
out.swap(in);
}
break;
case CompressionCodec::SNAPPY:
{
size_t compressed_size;
m_tmp.resize(snappy::MaxCompressedLength(in.size()));
snappy::RawCompress((char const *) in.data(),
in.size(),
(char *) m_tmp.data(),
&compressed_size);
m_tmp.resize(compressed_size);
out.assign(m_tmp.begin(), m_tmp.end());
}
break;
case CompressionCodec::GZIP:
{
int window_bits = 15 + 16; // maximum window + GZIP
z_stream stream;
memset(&stream, '\0', sizeof(stream));
int rv = deflateInit2(&stream,
Z_DEFAULT_COMPRESSION,
Z_DEFLATED,
window_bits,
9,
Z_DEFAULT_STRATEGY);
if (rv != Z_OK) {
cerr << "deflateInit2 failed: " << rv;
exit(1);
}
m_tmp.resize(deflateBound(&stream, in.size()));
stream.next_in =
const_cast<Bytef*>(reinterpret_cast<const Bytef*>(in.data()));
stream.avail_in = in.size();
stream.next_out = (Bytef*) m_tmp.data();
stream.avail_out = m_tmp.size();
rv = deflate(&stream, Z_FINISH);
if (rv != Z_STREAM_END) {
cerr << "gzip deflate failed: " << rv;
exit(1);
}
out.assign(m_tmp.begin(), m_tmp.begin() + stream.total_out);
deflateEnd(&stream);
}
break;
default:
cerr << "unsupported compression codec: " << int(m_compression_codec);
exit(1);
break;
}
}
示例4:
option& set_default_value( const Value& _value ) {
check_option_necessity();
value = boost::lexical_cast< std::string >( _value );
default_value.assign( value.begin(), value.end() );
return *this;
}
示例5: handleToolTip
BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen )
{
BOOL handled = FALSE;
if (gDisconnected)
{
return FALSE;
}
LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(viewPosToGlobal(x, y, gSavedSettings.getBOOL( "MiniMapRotate" )));
if( region )
{
msg.assign("");
std::string fullname;
if(mClosestAgentToCursor.notNull() && gCacheName->getFullName(mClosestAgentToCursor, fullname))
{
//msg.append(fullname);
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.0b
// [Ansariel: Display name support]
// msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname) );
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
{
msg.append(RlvStrings::getAnonym(fullname));
}
else
{
if (LLAvatarNameCache::useDisplayNames())
{
LLAvatarName avatar_name;
if (LLAvatarNameCache::get(mClosestAgentToCursor, &avatar_name))
{
static const LLCachedControl<S32> phoenix_name_system("PhoenixNameSystem", 0);
if (phoenix_name_system == 2 || (phoenix_name_system == 1 && avatar_name.mIsDisplayNameDefault))
{
fullname = avatar_name.mDisplayName;
}
else
{
fullname = avatar_name.getCompleteName(true);
}
}
}
msg.append(fullname);
}
// [/Ansariel: Display name support]
// [/RLVa:KB]
msg.append("\n");
LLVector3d mypos = gAgent.getPositionGlobal();
LLVector3d position = mClosestAgentPosition;
if ( LLFloaterAvatarList::instanceExists() )
{
LLAvatarListEntry *ent = LLFloaterAvatarList::getInstance()->getAvatarEntry(mClosestAgentToCursor);
if ( NULL != ent )
{
//position = LLFloaterAvatarList::AvatarPosition(mClosestAgentToCursor);
position = ent->getPosition();
}
}
LLVector3d delta = position - mypos;
F32 distance = (F32)delta.magVec();
//llinfos << distance << " - " << position << llendl;
msg.append( llformat("\n(Distance: %.02fm)\n\n",distance) );
}
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-0.2.0b
msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? region->getName() : RlvStrings::getString(RLV_STRING_HIDDEN) );
// [/RLVa:KB]
//msg.append( region->getName() );
//#ifndef LL_RELEASE_FOR_DOWNLOAD
std::string buffer;
msg.append("\n");
buffer = region->getHost().getHostName();
msg.append(buffer);
msg.append("\n");
buffer = region->getHost().getString();
msg.append(buffer);
//#endif
msg.append("\n");
msg.append(getToolTip());
S32 SLOP = 4;
localPointToScreen(
x - SLOP, y - SLOP,
&(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
handled = TRUE;
}
if(!handled)
{
return LLPanel::handleToolTip(x, y, msg, sticky_rect_screen);
}
return handled;
}
示例6: EchoBinary
void ProviderTestBasic::EchoBinary(IDvInvocationStd& /*aInvocation*/, const std::string& aValue, std::string& aResult)
{
aResult.assign(aValue);
}
示例7: main
int main(int argc,char *argv[])
{
{
#ifdef MULTITHREAD_STDLOCALE_WORKAROUND
// Note: there's a known threading bug regarding std::locale with MSVC according to
// http://connect.microsoft.com/VisualStudio/feedback/details/492128/std-locale-constructor-modifies-global-locale-via-setlocale
int iPreviousFlag = ::_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
#endif
using std::locale;
locale::global(locale(locale::classic(), "", locale::collate | locale::ctype));
#ifdef MULTITHREAD_STDLOCALE_WORKAROUND
if (iPreviousFlag > 0 )
::_configthreadlocale(iPreviousFlag);
#endif
}
TASPlayer::Init();
SetThreadAffinityMask(GetCurrentThread(),1);
//printf("%08x",opsize); //AGAIN?!
char *t;
initArchiveSystem();
if(timeBeginPeriod(1) != TIMERR_NOERROR)
{
AddLogText("Error setting timer granularity to 1ms.", DO_ADD_NEWLINE);
}
InitCommonControls();
debugSystem = new DebugSystem();
if(!FCEUI_Initialize())
{
do_exit();
return 1;
}
ApplyDefaultCommandMapping();
fceu_hInstance = GetModuleHandle(0);
fceu_hAccel = LoadAccelerators(fceu_hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR1));
// Get the base directory
GetBaseDirectory();
// load fceux.cfg
sprintf(TempArray,"%s\\%s",BaseDirectory.c_str(),cfgFile.c_str());
LoadConfig(TempArray);
//initDirectories();
// Parse the commandline arguments
t = ParseArgies(argc, argv);
int saved_pal_setting = !!pal_emulation;
if (ConfigToLoad)
{
// alternative config file specified
cfgFile.assign(ConfigToLoad);
// Load the config information
sprintf(TempArray,"%s\\%s",BaseDirectory.c_str(),cfgFile.c_str());
LoadConfig(TempArray);
}
//Bleh, need to find a better place for this.
{
FCEUI_SetGameGenie(genie!=0);
fullscreen = !!fullscreen;
soundo = !!soundo;
frame_display = !!frame_display;
allowUDLR = !!allowUDLR;
pauseAfterPlayback = !!pauseAfterPlayback;
closeFinishedMovie = !!closeFinishedMovie;
EnableBackgroundInput = !!EnableBackgroundInput;
KeyboardSetBackgroundAccess(EnableBackgroundInput!=0);
JoystickSetBackgroundAccess(EnableBackgroundInput!=0);
FCEUI_SetSoundVolume(soundvolume);
FCEUI_SetSoundQuality(soundquality);
FCEUI_SetTriangleVolume(soundTrianglevol);
FCEUI_SetSquare1Volume(soundSquare1vol);
FCEUI_SetSquare2Volume(soundSquare2vol);
FCEUI_SetNoiseVolume(soundNoisevol);
FCEUI_SetPCMVolume(soundPCMvol);
}
//Since a game doesn't have to be loaded before the GUI can be used, make
//sure the temporary input type variables are set.
ParseGIInput(NULL);
// Initialize default directories
//.........这里部分代码省略.........
示例8:
void
prepare_string(
const char* input,
size_t size) {
_prepare.assign(input, size);
}
示例9: wWinMain
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpstrCmdLine, int nCmdShow) {
g_hInstance = hInstance;
json_value* appSettings = GetApplicationSettings();
if (GetApplicationSettingsError().length()) {
std::string error = GetApplicationSettingsError();
error.append("\nApplication will terminate immediately. ");
FatalError(NULL, error);
}
// Debugging options.
bool show_console = (*appSettings)["debugging"]["show_console"];
bool subprocess_show_console = (*appSettings)["debugging"]["subprocess_show_console"];
std::string log_level = (*appSettings)["debugging"]["log_level"];
std::string log_file = (*appSettings)["debugging"]["log_file"];
log_file = GetAbsolutePath(log_file);
// Initialize logging.
if (std::wstring(lpstrCmdLine).find(L"--type=") != std::string::npos) {
// This is a subprocess.
InitializeLogging(subprocess_show_console, log_level, log_file);
} else {
// Main browser process.
InitializeLogging(show_console, log_level, log_file);
}
// Command line arguments
LPWSTR *argv;
int argc;
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argv) {
for (int i = 0; i < argc; i++) {
std::string argument = WideToUtf8(std::wstring(argv[i]));
size_t pos = argument.find("=");
if (pos != std::string::npos) {
std::string name = argument.substr(0, pos);
std::string value = argument.substr(pos+1, std::string::npos);
if (name == "--cgi-environment" && value.length()) {
g_cgiEnvironmentFromArgv.assign(value);
}
}
}
} else {
LOG_WARNING << "CommandLineToArgvW() failed";
}
// CEF subprocesses.
CefMainArgs main_args(hInstance);
CefRefPtr<App> app(new App);
int exit_code = CefExecuteProcess(main_args, app.get(), NULL);
if (exit_code >= 0) {
ShutdownLogging();
return exit_code;
}
LOG_INFO << "--------------------------------------------------------";
LOG_INFO << "Started application";
if (log_file.length())
LOG_INFO << "Logging to: " << log_file;
else
LOG_INFO << "No logging file set";
LOG_INFO << "Log level = "
<< FILELog::ToString(FILELog::ReportingLevel());
// Main window title option.
std::string main_window_title = (*appSettings)["main_window"]["title"];
if (main_window_title.empty())
main_window_title = GetExecutableName();
// Single instance guid option.
const char* single_instance_guid =
(*appSettings)["application"]["single_instance_guid"];
if (single_instance_guid && single_instance_guid[0] != 0) {
int guidSize = strlen(single_instance_guid) + 1;
g_singleInstanceApplicationGuid = new wchar_t[guidSize];
Utf8ToWide(single_instance_guid, g_singleInstanceApplicationGuid,
guidSize);
}
if (g_singleInstanceApplicationGuid
&& g_singleInstanceApplicationGuid[0] != 0) {
g_singleInstanceApplication.Initialize(
g_singleInstanceApplicationGuid);
if (g_singleInstanceApplication.IsRunning()) {
HWND hwnd = FindWindow(g_singleInstanceApplicationGuid, NULL);
if (hwnd) {
if (IsIconic(hwnd))
ShowWindow(hwnd, SW_RESTORE);
SetForegroundWindow(hwnd);
return 0;
}
}
}
// Window class name.
if (g_singleInstanceApplicationGuid) {
swprintf_s(g_windowClassName, _countof(g_windowClassName), L"%s",
g_singleInstanceApplicationGuid);
} else {
swprintf_s(g_windowClassName, _countof(g_windowClassName), L"%s",
//.........这里部分代码省略.........
示例10: WriteTraceAndMetadataFiles
//--------------------------------------------------------------------------
/// Write a trace's metadata file and return the contenst through the out-param.
/// \param inFullResponseString The full response string for a collected linked trace request.
/// \param outMetadataXML The XML metadata string to return to the client.
/// \returns True if writing the metadata file was successful.
//--------------------------------------------------------------------------
bool MultithreadedTraceAnalyzerLayer::WriteTraceAndMetadataFiles(const std::stringstream& inFullResponseString, std::string& outMetadataXML)
{
bool bWrittenSuccessfully = false;
// Empty out the incoming path to the metadata file. We'll know the exact path later.
outMetadataXML.assign("");
osModuleArchitecture moduleArchitecture;
osRuntimePlatform currentPlatform;
gtString executablePath;
gtString commandLine;
gtString workingDirectory;
// Retrieve the name of the instrumented application. Construct a metadata filename which references it.
if (osGetProcessLaunchInfo(osGetCurrentProcessId(), moduleArchitecture, currentPlatform, executablePath, commandLine, workingDirectory) == true)
{
osFilePath executableFilepath;
executableFilepath.setFullPathFromString(executablePath);
gtString appName;
if (executableFilepath.getFileName(appName) == true)
{
osTime currentTime;
currentTime.setFromCurrentTime();
tm timeStruct;
currentTime.timeAsTmStruct(timeStruct, osTime::LOCAL);
// Need to add 1900, since tm contains "years since 1900".
int year = timeStruct.tm_year + 1900;
// Need to add 1, since tm contains "months since January".
int month = timeStruct.tm_mon + 1;
int day = timeStruct.tm_mday;
int hour = timeStruct.tm_hour;
int minute = timeStruct.tm_min;
int second = timeStruct.tm_sec;
gtASCIIString metadataFilename;
// ExecutableFilename-YEAR-MM-DD-HOUR-MINUTE-SECOND
metadataFilename.appendFormattedString("description-%s-%d-%d-%d-%d-%d-%d.xml",
appName.asASCIICharArray(),
year, month, day,
hour, minute, second);
// Build a path to the GPS folder within the Temp directory.
osFilePath systemTempDirectory;
systemTempDirectory.setPath(osFilePath::OS_TEMP_DIRECTORY);
gtString toolDirectory;
#ifdef CODEXL_GRAPHICS
toolDirectory.fromASCIIString("CodeXL");
#else
toolDirectory.fromASCIIString(GetPerfStudioDirName());
#endif
// @TODO: Construct a path from the temp + tool directory.
systemTempDirectory.appendSubDirectory(toolDirectory);
gtList<osFilePath> toolDirectoryPaths;
osDirectory d;
d.setDirectoryPath(systemTempDirectory);
// @TODO: Find a better way to create the "Session" directory. We shouldn't need to search through existing session directories.
int maxSessionIndex = 0;
bool bGotSubDirectories = d.getSubDirectoriesPaths(osDirectory::SORT_BY_NAME_DESCENDING, toolDirectoryPaths);
if (bGotSubDirectories)
{
// Step through each directory, and look for "Session" folders.
gtList<osFilePath>::iterator subdirectoryIter;
for (subdirectoryIter = toolDirectoryPaths.begin(); subdirectoryIter != toolDirectoryPaths.end(); ++subdirectoryIter)
{
gtString subdirString;
osFilePath subdir = *subdirectoryIter;
subdir.getFileName(subdirString);
if (subdir.isDirectory() && subdirString.startsWith(L"Session"))
{
// Remove the "Session" part of the string. We're only interested in the number at the end.
subdirString.replace(L"Session", L"", true);
const char* sessionIndexAsString = subdirString.asASCIICharArray();
int thisSessionId = atoi(sessionIndexAsString);
if (thisSessionId > maxSessionIndex)
{
maxSessionIndex = thisSessionId;
}
}
}
}
//.........这里部分代码省略.........
示例11: getSignature
/*++
* @method: oAuth::getSignature
*
* @description: this method calculates HMAC-SHA1 signature of OAuth header
*
* @input: eType - HTTP request type
* rawUrl - raw url of the HTTP request
* rawKeyValuePairs - key-value pairs containing OAuth headers and HTTP data
*
* @output: oAuthSignature - base64 and url encoded signature
*
* @remarks: internal method
*
*--*/
bool oAuth::getSignature( const eOAuthHttpRequestType eType,
const std::string& rawUrl,
const oAuthKeyValuePairs& rawKeyValuePairs,
std::string& oAuthSignature )
{
std::string rawParams;
std::string paramsSeperator;
std::string sigBase;
/* Initially empty signature */
oAuthSignature.assign( "" );
/* Build a string using key-value pairs */
paramsSeperator = "&";
getStringFromOAuthKeyValuePairs( rawKeyValuePairs, rawParams, paramsSeperator );
/* Start constructing base signature string. Refer http://dev.twitter.com/auth#intro */
switch( eType )
{
case eOAuthHttpGet:
{
sigBase.assign( "GET&" );
}
break;
case eOAuthHttpPost:
{
sigBase.assign( "POST&" );
}
break;
case eOAuthHttpDelete:
{
sigBase.assign( "DELETE&" );
}
break;
default:
{
return false;
}
break;
}
sigBase.append( urlencode( rawUrl ) );
sigBase.append( "&" );
sigBase.append( urlencode( rawParams ) );
/* Now, hash the signature base string using HMAC_SHA1 class */
CHMAC_SHA1 objHMACSHA1;
std::string secretSigningKey;
unsigned char strDigest[oAuthLibDefaults::OAUTHLIB_BUFFSIZE_LARGE];
memset( strDigest, 0, oAuthLibDefaults::OAUTHLIB_BUFFSIZE_LARGE );
/* Signing key is composed of consumer_secret&token_secret */
secretSigningKey.assign( m_consumerSecret );
secretSigningKey.append( "&" );
if( m_oAuthTokenSecret.length() )
{
secretSigningKey.append( m_oAuthTokenSecret );
}
objHMACSHA1.HMAC_SHA1( (unsigned char*)sigBase.c_str(),
sigBase.length(),
(unsigned char*)secretSigningKey.c_str(),
secretSigningKey.length(),
strDigest );
/* Do a base64 encode of signature */
std::string base64Str = base64_encode( strDigest, 20 /* SHA 1 digest is 160 bits */ );
/* Do an url encode */
oAuthSignature = urlencode( base64Str );
return ( oAuthSignature.length() ) ? true : false;
}
示例12: Get
bool CScraperUrl::Get(const SUrlEntry& scrURL, std::string& strHTML, XFILE::CCurlFile& http, const CStdString& cacheContext)
{
CURL url(scrURL.m_url);
http.SetReferer(scrURL.m_spoof);
CStdString strCachePath;
if (scrURL.m_isgz)
http.SetContentEncoding("gzip");
if (!scrURL.m_cache.empty())
{
strCachePath = URIUtils::AddFileToFolder(g_advancedSettings.m_cachePath,
"scrapers/" + cacheContext + "/" + scrURL.m_cache);
if (XFILE::CFile::Exists(strCachePath))
{
XFILE::CFile file;
XFILE::auto_buffer buffer;
if (file.LoadFile(strCachePath, buffer))
{
strHTML.assign(buffer.get(), buffer.length());
return true;
}
}
}
CStdString strHTML1(strHTML);
if (scrURL.m_post)
{
CStdString strOptions = url.GetOptions();
strOptions = strOptions.substr(1);
url.SetOptions("");
if (!http.Post(url.Get(), strOptions, strHTML1))
return false;
}
else
if (!http.Get(url.Get(), strHTML1))
return false;
strHTML = strHTML1;
std::string mimeType(http.GetMimeType());
CMime::EFileType ftype = CMime::GetFileTypeFromMime(mimeType);
if (ftype == CMime::FileTypeUnknown)
ftype = CMime::GetFileTypeFromContent(strHTML);
if (ftype == CMime::FileTypeZip || ftype == CMime::FileTypeGZip)
{
XFILE::CZipFile file;
std::string strBuffer;
int iSize = file.UnpackFromMemory(strBuffer,strHTML,scrURL.m_isgz); // FIXME: use FileTypeGZip instead of scrURL.m_isgz?
if (iSize > 0)
{
strHTML = strBuffer;
CLog::Log(LOGDEBUG, "%s: Archive \"%s\" was unpacked in memory", __FUNCTION__, scrURL.m_url.c_str());
}
else
CLog::Log(LOGWARNING, "%s: \"%s\" looks like archive, but cannot be unpacked", __FUNCTION__, scrURL.m_url.c_str());
}
std::string reportedCharset(http.GetServerReportedCharset());
if (ftype == CMime::FileTypeHtml)
{
std::string realHtmlCharset, converted;
if (!CCharsetDetection::ConvertHtmlToUtf8(strHTML, converted, reportedCharset, realHtmlCharset))
CLog::Log(LOGWARNING, "%s: Can't find precise charset for HTML \"%s\", using \"%s\" as fallback", __FUNCTION__, scrURL.m_url.c_str(), realHtmlCharset.c_str());
else
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for HTML \"%s\"", __FUNCTION__, realHtmlCharset.c_str(), scrURL.m_url.c_str());
strHTML = converted;
}
else if (ftype == CMime::FileTypeXml)
{
CXBMCTinyXML xmlDoc;
xmlDoc.Parse(strHTML, reportedCharset);
std::string realXmlCharset(xmlDoc.GetUsedCharset());
if (!realXmlCharset.empty())
{
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for XML \"%s\"", __FUNCTION__, realXmlCharset.c_str(), scrURL.m_url.c_str());
std::string converted;
g_charsetConverter.ToUtf8(realXmlCharset, strHTML, converted);
strHTML = converted;
}
}
else if (ftype == CMime::FileTypePlainText || StringUtils::CompareNoCase(mimeType.substr(0, 5), "text/") == 0)
{
std::string realTextCharset, converted;
CCharsetDetection::ConvertPlainTextToUtf8(strHTML, converted, reportedCharset, realTextCharset);
strHTML = converted;
if (reportedCharset != realTextCharset)
CLog::Log(LOGWARNING, "%s: Using \"%s\" charset for plain text \"%s\" instead of server reported \"%s\" charset", __FUNCTION__, realTextCharset.c_str(), scrURL.m_url.c_str(), reportedCharset.c_str());
else
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for plain text \"%s\"", __FUNCTION__, realTextCharset.c_str(), scrURL.m_url.c_str());
}
else if (!reportedCharset.empty())
{
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for \"%s\"", __FUNCTION__, reportedCharset.c_str(), scrURL.m_url.c_str());
if (reportedCharset != "UTF-8")
//.........这里部分代码省略.........
示例13: handleDragAndDrop
// virtual
BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask,
BOOL drop, EDragAndDropType cargo_type, void *cargo_data,
EAcceptance *accept,
std::string& tooltip_msg)
{
BOOL handled = FALSE;
LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource();
if (LLToolDragAndDrop::SOURCE_NOTECARD == source)
{
// We currently do not handle dragging items from one notecard to another
// since items in a notecard must be in Inventory to be verified. See DEV-2891.
return FALSE;
}
if (getEnabled() && acceptsTextInput())
{
switch( cargo_type )
{
case DAD_CALLINGCARD:
case DAD_TEXTURE:
case DAD_SOUND:
case DAD_LANDMARK:
case DAD_SCRIPT:
case DAD_CLOTHING:
case DAD_OBJECT:
case DAD_NOTECARD:
case DAD_BODYPART:
case DAD_ANIMATION:
case DAD_GESTURE:
case DAD_MESH:
{
LLInventoryItem *item = (LLInventoryItem *)cargo_data;
if( item && allowsEmbeddedItems() )
{
U32 mask_next = item->getPermissions().getMaskNextOwner();
if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
{
if( drop )
{
deselect();
S32 old_cursor = mCursorPos;
setCursorAtLocalPos( x, y, TRUE );
S32 insert_pos = mCursorPos;
setCursorPos(old_cursor);
BOOL inserted = insertEmbeddedItem( insert_pos, item );
if( inserted && (old_cursor > mCursorPos) )
{
setCursorPos(mCursorPos + 1);
}
needsReflow();
}
*accept = ACCEPT_YES_COPY_MULTI;
}
else
{
*accept = ACCEPT_NO;
if (tooltip_msg.empty())
{
// *TODO: Translate
tooltip_msg.assign("Only items with unrestricted\n"
"'next owner' permissions \n"
"can be attached to notecards.");
}
}
}
else
{
*accept = ACCEPT_NO;
}
break;
}
default:
*accept = ACCEPT_NO;
break;
}
}
else
{
// Not enabled
*accept = ACCEPT_NO;
}
handled = TRUE;
LL_DEBUGS("UserInput") << "dragAndDrop handled by LLViewerTextEditor " << getName() << LL_ENDL;
return handled;
}
示例14: getString
void ValueImpl::getString(std::string& ret) const
{
if (null)
throw NullValue();
ret.assign(data);
}
示例15: find_include_file
static bool find_include_file(std::string &srcincpath, int srcrootlen, int dstrootlen, std::string &srcfile, std::string &dstfile, std::string &filename)
{
// iterate over include paths and find the file
for (include_path *curpath = incpaths; curpath != nullptr; curpath = curpath->next)
{
// a '.' include path is specially treated
if (curpath->path.compare(".") == 0)
srcincpath.assign(srcfile.substr(0, srcfile.find_last_of(PATH_SEPARATOR[0])));
else
srcincpath.assign(srcfile.substr(0, srcrootlen + 1)).append(curpath->path);
// append the filename piecemeal to account for directories
int lastsepindex = 0;
int sepindex;
while ((sepindex = filename.find_first_of('/', lastsepindex)) != -1)
{
// handle .. by removing a chunk from the incpath
std::string pathpart(filename, lastsepindex, sepindex - lastsepindex);
if (pathpart.compare("..")==0)
{
sepindex = srcincpath.find_last_of(PATH_SEPARATOR[0]);
if (sepindex != -1)
srcincpath.substr(0, sepindex);
}
// otherwise, append a path separator and the pathpart
else
srcincpath.append(PATH_SEPARATOR).append(pathpart);
// advance past the previous index
lastsepindex = sepindex + 1;
}
// now append the filename
srcincpath.append(PATH_SEPARATOR).append(filename.substr(lastsepindex, -1));
// see if we can open it
util::core_file::ptr testfile;
if (util::core_file::open(srcincpath, OPEN_FLAG_READ, testfile) == osd_file::error::NONE)
{
// close the file
testfile.reset();
// find the longest matching directory substring between the include and source file
lastsepindex = 0;
while ((sepindex = srcincpath.find_first_of(PATH_SEPARATOR[0], lastsepindex)) != -1)
{
// get substrings up to the current directory
std::string tempfile(srcfile, 0, sepindex);
std::string tempinc(srcincpath, 0, sepindex);
// if we don't match, stop
if (tempfile.compare(tempinc)!=0)
break;
lastsepindex = sepindex + 1;
}
// chop off the common parts of the paths
std::string tempfile(srcfile, lastsepindex, -1);
srcincpath = srcincpath.substr(lastsepindex, -1);
strreplacechr(srcincpath, PATH_SEPARATOR[0], '/');
// for each directory left in the filename, we need to prepend a "../"
while ((sepindex = tempfile.find_first_of(PATH_SEPARATOR[0])) != -1)
{
tempfile.substr(sepindex + 1, -1);
srcincpath.insert(0, "../");
}
srcincpath.append(".html");
// free the strings and return the include path
return true;
}
}
return false;
}