本文整理汇总了C++中UT_String::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_String::clear方法的具体用法?C++ UT_String::clear怎么用?C++ UT_String::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_String
的用法示例。
在下文中一共展示了UT_String::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDefaultApp
static void getDefaultApp(UT_String &imageApp, bool &bLeaveImageAsPNG)
{
#ifdef WIN32
bLeaveImageAsPNG = false;
imageApp.clear();
char buffer[MAX_PATH];
// for WinNT mspaint is most likely in the system directory (eg C:\WINNT\SYSTEM32\MSPAINT.EXE)
if (GetSystemDirectory(buffer, MAX_PATH))
{
imageApp = buffer;
imageApp += "\\MSPAINT.EXE";
UT_DEBUGMSG(("ABIPAINT: Checking if %s exists\n", imageApp.c_str()));
if (!UT_isRegularFile(imageApp.c_str()))
imageApp.clear();
}
// if not there, try in Win95b directory (eg %PROGRAMFILES%\ACCESSORIES\MSPAINT.EXE)
if (imageApp.empty())
{
HKEY hKey;
unsigned long lType;
DWORD dwSize;
unsigned char* szValue = NULL;
if( ::RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS )
{
if( ::RegQueryValueEx( hKey, "ProgramFilesDir", NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS )
{
szValue = new unsigned char[dwSize + 1];
::RegQueryValueEx( hKey, "ProgramFilesDir", NULL, &lType, szValue, &dwSize);
imageApp = (char*) szValue;
delete[] szValue;
imageApp += "\\ACCESSORIES\\MSPAINT.EXE";
UT_DEBUGMSG(("ABIPAINT: Checking if %s exists\n", imageApp.c_str()));
if (!UT_isRegularFile(imageApp.c_str()))
imageApp.clear();
}
::RegCloseKey(hKey);
}
}
// if we still haven't found the file, then simply try mspaint.exe
if (imageApp.empty())
{
imageApp = "mspaint.exe";
UT_DEBUGMSG(("ABIPAINT: Falling back to %s (will probably fail)\n", imageApp.c_str()));
}
#else
// for other platforms default to the GIMP, assume in path
bLeaveImageAsPNG = true;
imageApp = "gimp";
#endif
}
示例2: setFontDecoration
void XAP_Dialog_FontChooser::setFontDecoration(bool bUnderline, bool bOverline, bool bStrikeOut, bool bTopline, bool bBottomline)
{
m_bUnderline = bUnderline;
m_bOverline = bOverline;
m_bStrikeout = bStrikeOut;
m_bTopline = bTopline;
m_bBottomline = bBottomline;
static gchar s[50];
UT_String decors;
decors.clear();
if(bUnderline)
decors += "underline ";
if(bStrikeOut)
decors += "line-through ";
if(bOverline)
decors += "overline ";
if(bTopline)
decors += "topline ";
if(bBottomline)
decors += "bottomline ";
if(!bUnderline && !bStrikeOut && !bOverline && !bTopline && !bBottomline)
decors = "none";
sprintf(s,"%s",decors.c_str());
addOrReplaceVecProp("text-decoration",(const gchar *) s);
}
示例3: UT_String_removeProperty
/*!
* Assuming a string of standard abiword properties eg. "fred:nerk; table-width:1.0in; table-height:10.in"
* Remove the property sProp and it's value from the string of properties.
*/
void UT_String_removeProperty(UT_String & sPropertyString, const UT_String & sProp)
{
UT_String sWork ( sProp );
sWork += ":";
const char * szWork = sWork.c_str();
const char * szProps = sPropertyString.c_str();
const char * szLoc = strstr(szProps,szWork);
if(szLoc == NULL)
{
//
// Not here, do nothing
return ;
}
//
// Found it, Get left part.
//
UT_sint32 locLeft = static_cast<UT_sint32>(reinterpret_cast<size_t>(szLoc) - reinterpret_cast<size_t>(szProps));
UT_String sLeft;
if(locLeft == 0)
{
sLeft.clear();
}
else
{
sLeft = sPropertyString.substr(0,locLeft);
}
locLeft = static_cast<UT_sint32>(sLeft.size());
if(locLeft > 0)
{
//
// If this element is the last item in the properties there is no "; ".
//
// Remove trailing ';' and ' '
//
locLeft--;
while(locLeft >= 0 && (sLeft[locLeft] == ';' || sLeft[locLeft] == ' '))
{
locLeft--;
}
}
UT_String sNew;
if(locLeft > 0)
{
sNew = sLeft.substr(0,locLeft+1);
}
else
{
sNew.clear();
}
//
// Look for ";" to get right part
//
const char * szDelim = strchr(szLoc,';');
if(szDelim == NULL)
{
//
// No properties after this, just assign and return
//
sPropertyString = sNew;
}
else
{
//
// Just slice off the properties and tack them onto the pre-existing sNew
//
while(*szDelim == ';' || *szDelim == ' ')
{
szDelim++;
}
UT_sint32 offset = static_cast<UT_sint32>(reinterpret_cast<size_t>(szDelim) - reinterpret_cast<size_t>(szProps));
UT_sint32 iLen = sPropertyString.size() - offset;
if(sNew.size() > 0)
{
sNew += "; ";
}
sNew += sPropertyString.substr(offset,iLen);
sPropertyString = sNew;
}
}