本文整理汇总了C++中UT_String::length方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_String::length方法的具体用法?C++ UT_String::length怎么用?C++ UT_String::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_String
的用法示例。
在下文中一共展示了UT_String::length方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fileTypeChanged
void XAP_UnixDialog_FileOpenSaveAs::fileTypeChanged(GtkWidget * w)
{
if (!m_bSave)
return;
UT_sint32 nFileType = XAP_comboBoxGetActiveInt(GTK_COMBO_BOX(w));
UT_DEBUGMSG(("File type widget is %p filetype number is %d \n",w,nFileType));
// I have no idea for 0, but XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO
// definitely means "skip this"
if((nFileType == 0) || (nFileType == XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO))
{
return;
}
gchar * filename = gtk_file_chooser_get_filename(m_FC);
UT_String sFileName = filename;
FREEP(filename);
UT_String sSuffix = m_szSuffixes[nFileType-1];
sSuffix = sSuffix.substr(1,sSuffix.length()-1);
UT_sint32 i = 0;
bool bFoundComma = false;
for(i=0; i< static_cast<UT_sint32>(sSuffix.length()); i++)
{
if(sSuffix[i] == ';')
{
bFoundComma = true;
break;
}
}
if(bFoundComma)
{
sSuffix = sSuffix.substr(0,i);
}
//
// Hard code a suffix
//
if(strstr(sSuffix.c_str(),"gz") != NULL)
{
sSuffix = ".zabw";
}
bool bFoundSuffix = false;
for(i= sFileName.length()-1; i> 0; i--)
{
if(sFileName[i] == '.')
{
bFoundSuffix = true;
break;
}
}
if(!bFoundSuffix)
{
return;
}
sFileName = sFileName.substr(0,i);
sFileName += sSuffix;
gtk_file_chooser_set_current_name(m_FC, UT_basename(sFileName.c_str()));
}
示例2: UT_Compare
int UT_Compare( const UT_String& rhs, const UT_String& lhs )
{
#if defined(TARGET_IOS) || defined(TARGET_MACOS)
CFStringRef theString1 = CFStringCreateWithCharactersNoCopy( 0, rhs.data(), rhs.length(), kCFAllocatorNull );
CFStringRef theString2 = CFStringCreateWithCharactersNoCopy( 0, lhs.data(), lhs.length(), kCFAllocatorNull );
CFComparisonResult result = CFStringCompare( theString1, theString2, kCFCompareLocalized );
CFRelease( theString1 );
CFRelease( theString2 );
return result;
#else
return rhs.compare(lhs);
#endif
}
示例3: UT_W2S
//======================== METHOD DECLARATION =======================
// METHOD NAME : UT_W2S
//---------------------------------------------------------------------
/// \param src
/// \param dst
/// \return
//---------------------------------------------------------------------
// DESCRIPTION :
/// Convert a 'wstring' to a string.
//=====================================================================
void UT_W2S( const UT_String &src, string &dst )
{
#if defined(TARGET_IOS) || defined(TARGET_MACOS)
CFStringRef strref = CFStringCreateWithCharactersNoCopy( 0, src.data(), src.length(), kCFAllocatorNull );
CFIndex usedBufLen;
CFStringGetBytes( strref, CFRangeMake( 0, src.length() ), CFStringGetSystemEncoding(), '?', false, NULL, 0, &usedBufLen );
char *buffer = (char*)MEM_ALLOC(usedBufLen * sizeof(char));
CFStringGetBytes( strref, CFRangeMake( 0, src.length() ), CFStringGetSystemEncoding(), '?', false, (UInt8 *) buffer, usedBufLen, &usedBufLen );
CFRelease( strref );
dst.assign( buffer, usedBufLen );
MEM_DEALLOC(buffer);
if ( ! dst.empty() )
dst.erase(dst.begin(), dst.end());
copy( src.begin(), src.end(), back_inserter( dst ));
#else
#ifndef TARGET_WIN32
dst = string();
if (src.length() < 1)
{
return;
}
unsigned char *dstC = (unsigned char*)MEM_ALLOC(6 * src.length() * sizeof(unsigned char));
unsigned char *initial = dstC;
UTF16 *srcC = const_cast<UTF16*>(src.c_str());
ConvertUTF16toUTF8(&srcC, srcC + src.length(), &dstC, dstC + 6 * src.length());
dst.append((const char *)dstC);
MEM_DEALLOC(initial);
#else // TARGET_WIN32
(void)src;
(void)dst;
#endif
#endif
}
示例4: _splitDirectoryAndFileName
/**
* Takes a string like "./ObjectReplacements/Object 1" and split it into
* subdirectory name ("ObjectReplacements") and file name ("Object 1").
*/
void ODi_Abi_Data::_splitDirectoryAndFileName(const gchar* pHRef, UT_String& dirName, UT_String& fileName) const {
UT_String href;
UT_String str;
int iStart, nChars, i, len;
href = pHRef;
////
// Get the directory name
str = href.substr(0, 2);
if (str == "./") {
iStart = 2;
} else {
iStart = 0;
}
len = href.length();
for (i=iStart, nChars=0; i<len; i++) {
if (href[i] == '/') {
i=len; // exit loop
} else {
nChars++;
}
}
UT_ASSERT (nChars > 0 && nChars < len);
dirName = href.substr(iStart, nChars);
////
// Get the file name
iStart = iStart + nChars + 1;
nChars = len - iStart;
UT_ASSERT (nChars); // The file name must have at least one char.
fileName = href.substr(iStart, nChars);
}
示例5: GetShortPathName
bool XAP_Win32AppImpl::openURL(const char * szURL)
{
// NOTE: could get finer control over browser window via DDE
// NOTE: may need to fallback to WinExec for old NSCP versions
UT_String sURL = szURL;
// If this is a file:// URL, strip off file:// and make it backslashed
if (sURL.substr(0, 7) == "file://")
{
sURL = sURL.substr(7, sURL.size() - 7);
// View as WebPage likes to throw in an extra /\ just for fun, strip it off
if (sURL.substr(0, 2) == "/\\")
sURL = sURL.substr(2, sURL.size() - 2);
if (sURL.substr(0, 1) == "/")
sURL = sURL.substr(1, sURL.size() - 1);
// Convert all forwardslashes to backslashes
for (unsigned int i=0; i<sURL.length();i++)
if (sURL[i]=='/')
sURL[i]='\\';
// Convert from longpath to 8.3 shortpath, in case of spaces in the path
char* longpath = NULL;
char* shortpath = NULL;
longpath = new char[PATH_MAX];
shortpath = new char[PATH_MAX];
strcpy(longpath, sURL.c_str());
DWORD retval = GetShortPathName(longpath, shortpath, PATH_MAX);
if((retval == 0) || (retval > PATH_MAX))
{
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
DELETEP(longpath);
DELETEP(shortpath);
return false;
}
sURL = shortpath;
DELETEP(longpath);
DELETEP(shortpath);
}
// Query the registry for the default browser so we can directly invoke it
UT_String sBrowser;
HKEY hKey;
unsigned long lType;
DWORD dwSize;
unsigned char* szValue = NULL;
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, "http\\shell\\open\\command", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
if(RegQueryValueEx(hKey, NULL, NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)
{
szValue = new unsigned char[dwSize + 1];
RegQueryValueEx(hKey, NULL, NULL, &lType, szValue, &dwSize);
sBrowser = (char*) szValue;
DELETEP(szValue);
}
RegCloseKey(hKey);
}
/* Now that we have sBrowser from the registry, we need to parse it out.
* If the first character is a double-quote, everything up to and including
* the next double-quote is the sBrowser command. Everything after the
* double-quote is appended to the parameters.
* If the first character is NOT a double-quote, we assume
* everything up to the first whitespace is the command and anything after
* is appended to the parameters.
*/
int iDelimiter;
if (sBrowser.substr(0, 1) == "\"")
iDelimiter = UT_String_findCh(sBrowser.substr(1, sBrowser.length()-1), '"')+2;
else
iDelimiter = UT_String_findCh(sBrowser.substr(0, sBrowser.length()), ' ');
// Store params into a separate UT_String before we butcher sBrowser
UT_String sParams = sBrowser.substr(iDelimiter+1, sBrowser.length()-iDelimiter+1);
// Cut params off of sBrowser so all we're left with is the broweser path & executable
sBrowser = sBrowser.substr(0, iDelimiter);
// Check for a %1 passed in from the registry. If we find it,
// substitute our URL for %1. Otherwise, just append sURL to params.
const char *pdest = strstr(sParams.c_str(), "%1");
if (pdest != NULL)
{
int i = pdest - sParams.c_str() + 1;
sParams = sParams.substr(0, i-1) + sURL + sParams.substr(i+1, sParams.length()-i+1);
}
else
{
sParams = sParams + " " + sURL;
}
// Win95 doesn't like the Browser command to be quoted, so strip em off.
if (sBrowser.substr(0, 1) == "\"")
sBrowser = sBrowser.substr(1, sBrowser.length() - 1);
if (sBrowser.substr(sBrowser.length()-1, 1) == "\"")
sBrowser = sBrowser.substr(0, sBrowser.length() - 1);
//.........这里部分代码省略.........
示例6: s
#include "tf_test.h"
#include "ut_string_class.h"
#define TFSUITE "core.af.util.stringclass"
TFTEST_MAIN("UT_String")
{
UT_String s("foobar");
TFPASS(s.size() == 6);
TFPASS(s.length() == 6);
TFFAIL(s.empty());
TFPASS(s == "foobar");
TFPASS(s == UT_String("foobar"));
s += "baz";
TFPASS(s.size() == 9);
TFPASS(s == "foobarbaz");
s += UT_String("42");
TFPASS(s.size() == 11);
TFPASS(s == "foobarbaz42");
s += '!';
TFPASS(s.size() == 12);
TFPASS(s == "foobarbaz42!");
TFPASS(s[3] == 'b');
示例7: error
OP_ERROR
SOP_IdBlast::cookMySop(OP_Context &context)
{
fpreal now;
exint id;
GA_Offset start, end;
GA_PointGroup *group;
GA_ROAttributeRef id_gah;
GA_ROPageHandleI id_ph;
UT_String pattern;
UT_WorkArgs tokens;
IdOffsetMap id_map, srcid_map;
GroupIdMapPair pair;
now = context.getTime();
if (lockInputs(context) >= UT_ERROR_ABORT)
return error();
// Duplicate the incoming geometry.
duplicateSource(0, context);
// Get the id pattern.
IDS(pattern, now);
// If it's emptry, don't do anything.
if (pattern.length() == 0)
{
unlockInputs();
return error();
}
// Tokenize the range so we can handle multiple blocks.
pattern.tokenize(tokens, " ");
// Try to find the 'id' point attribute on the 1st input geometry.
id_gah = gdp->findPointAttribute(GA_SCOPE_PUBLIC, "id");
// If it doesn't exist, display a node error message and exit.
if (id_gah.isInvalid())
{
addError(SOP_MESSAGE, "Input geometry has no 'id' attribute.");
unlockInputs();
return error();
}
// Bind the page handles to the attributes.
id_ph.bind(id_gah.getAttribute());
// Iterate over all the points we selected.
for (GA_Iterator it(gdp->getPointRange()); it.blockAdvance(start, end); )
{
// Set the page handle to the start of this block.
id_ph.setPage(start);
// Iterate over all the points in the block.
for (GA_Offset pt = start; pt < end; ++pt)
{
// Get the 'id' value for the point.
id = id_ph.get(pt);
id_map[id] = pt;
}
}
// Create the group.
group = createAdhocPointGroup(*gdp);
// Add the group and the id map to the pair.
pair.first = group;
pair.second = &id_map;
// Iterate over each block in the tokens and add any ids to the group.
for (int i=0; i < tokens.getArgc(); ++i)
{
UT_String id_range(tokens[i]);
id_range.traversePattern(-1, &pair, addOffsetToGroup);
}
// Destroy the points.
gdp->destroyPointOffsets(GA_Range(*group));
unlockInputs();
return error();
}
示例8: readTags
void HoudiniScene::readTags( NameList &tags, bool includeChildren ) const
{
tags.clear();
const OP_Node *node = retrieveNode();
if ( !node )
{
return;
}
// add user supplied tags if we're not inside a SOP
if ( !m_contentIndex && node->hasParm( pTags.getToken() ) )
{
UT_String parmTagStr;
node->evalString( parmTagStr, pTags.getToken(), 0, 0 );
if ( !parmTagStr.equal( UT_String::getEmptyString() ) )
{
UT_WorkArgs tokens;
parmTagStr.tokenize( tokens, " " );
for ( int i = 0; i < tokens.getArgc(); ++i )
{
tags.push_back( tokens[i] );
}
}
}
// add tags from the registered tag readers
std::vector<CustomTagReader> &tagReaders = customTagReaders();
for ( std::vector<CustomTagReader>::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it )
{
NameList values;
it->m_read( node, values, includeChildren );
tags.insert( tags.end(), values.begin(), values.end() );
}
// add tags based on primitive groups
OBJ_Node *contentNode = retrieveNode( true )->castToOBJNode();
if ( contentNode && contentNode->getObjectType() == OBJ_GEOMETRY && m_splitter )
{
GU_DetailHandle newHandle = m_splitter->split( contentPathValue() );
if ( !newHandle.isNull() )
{
GU_DetailHandleAutoReadLock readHandle( newHandle );
if ( const GU_Detail *geo = readHandle.getGdp() )
{
GA_Range prims = geo->getPrimitiveRange();
for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() );
if ( group->getInternal() || group->isEmpty() )
{
continue;
}
const UT_String &groupName = group->getName();
if ( groupName.startsWith( tagGroupPrefix ) && group->containsAny( prims ) )
{
UT_String tag;
groupName.substr( tag, tagGroupPrefix.length() );
tag.substitute( "_", ":" );
tags.push_back( tag.buffer() );
}
}
}
}
}
}
示例9: hasTag
bool HoudiniScene::hasTag( const Name &name, bool includeChildren ) const
{
const OP_Node *node = retrieveNode();
if ( !node )
{
return false;
}
// check for user supplied tags if we're not inside a SOP
if ( !m_contentIndex && node->hasParm( pTags.getToken() ) )
{
UT_String parmTags;
node->evalString( parmTags, pTags.getToken(), 0, 0 );
if ( UT_String( name.c_str() ).multiMatch( parmTags ) )
{
return true;
}
}
// check with the registered tag readers
std::vector<CustomTagReader> &tagReaders = customTagReaders();
for ( std::vector<CustomTagReader>::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it )
{
if ( it->m_has( node, name ) )
{
return true;
}
}
// check tags based on primitive groups
OBJ_Node *contentNode = retrieveNode( true )->castToOBJNode();
if ( contentNode && contentNode->getObjectType() == OBJ_GEOMETRY && m_splitter )
{
GU_DetailHandle newHandle = m_splitter->split( contentPathValue() );
if ( !newHandle.isNull() )
{
GU_DetailHandleAutoReadLock readHandle( newHandle );
if ( const GU_Detail *geo = readHandle.getGdp() )
{
GA_Range prims = geo->getPrimitiveRange();
for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() );
if ( group->getInternal() || group->isEmpty() )
{
continue;
}
const UT_String &groupName = group->getName();
if ( groupName.startsWith( tagGroupPrefix ) && group->containsAny( prims ) )
{
UT_String tag;
groupName.substr( tag, tagGroupPrefix.length() );
tag.substitute( "_", ":" );
if ( tag.equal( name.c_str() ) )
{
return true;
}
}
}
}
}
}
return false;
}
示例10: _storeWindowData
void AP_Dialog_Options::_storeWindowData(void)
{
XAP_Prefs *pPrefs = m_pApp->getPrefs();
UT_return_if_fail (pPrefs);
AP_FrameData *pFrameData = NULL;
if(m_pFrame) {
pFrameData = (AP_FrameData *)m_pFrame->getFrameData();
UT_return_if_fail (pFrameData);
}
XAP_PrefsScheme *pPrefsScheme = pPrefs->getCurrentScheme();
UT_return_if_fail (pPrefsScheme);
// turn off all notification to PrefListeners via XAP_Prefs
pPrefs->startBlockChange();
// before we continue to remember all the changed values, check to see if
// we have turned OFF PrefsAutoSave. If so, toggle that value, then force
// a prefs save, then update everything else
// [email protected]
if ( pPrefs->getAutoSavePrefs() == true && _gatherPrefsAutoSave() == false ) {
pPrefs->setAutoSavePrefs( false );
pPrefs->savePrefsFile(); // TODO: check the results
}
else { // otherwise, just set the value
pPrefs->setAutoSavePrefs( _gatherPrefsAutoSave() );
}
// try again to make sure we've got an updatable scheme
pPrefsScheme = pPrefs->getCurrentScheme(true);
UT_return_if_fail (pPrefsScheme);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// save the values to the Prefs classes
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_AutoSpellCheck, _gatherSpellCheckAsType() );
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_AutoGrammarCheck, _gatherGrammarCheck() );
Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_SmartQuotesEnable, _gatherSmartQuotes() );
Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_CustomSmartQuotes, _gatherCustomSmartQuotes() );
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_SpellCheckCaps, _gatherSpellUppercase() );
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_SpellCheckNumbers, _gatherSpellNumbers() );
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_CursorBlink, _gatherViewCursorBlink() );
// Not implemented for UNIX or Win32. No need for it.
#if !defined(TOOLKIT_GTK) && !defined(TOOLKIT_COCOA) && !defined (TOOLKIT_WIN)
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_RulerVisible, _gatherViewShowRuler() );
UT_uint32 i;
for (i = 0; i < m_pApp->getToolbarFactory()->countToolbars(); i++) {
Save_Pref_Bool( pPrefsScheme, m_pApp->getToolbarFactory()->prefKeyForToolbar(i), _gatherViewShowToolbar(i));
}
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_StatusBarVisible, _gatherViewShowStatusBar() );
#endif
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_ParaVisible, _gatherViewUnprintable() );
#if defined(TOOLKIT_GTK)
Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_EnableSmoothScrolling, _gatherEnableSmoothScrolling() );
#endif
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_InsertModeToggle, _gatherEnableOverwrite() );
Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_AutoLoadPlugins, _gatherAutoLoadPlugins() );
Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_DefaultDirectionRtl, _gatherOtherDirectionRtl() );
Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_ChangeLanguageWithKeyboard, _gatherLanguageWithKeyboard() );
Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_DirMarkerAfterClosingParenthesis, _gatherDirMarkerAfterClosingParenthesis());
// JOAQUIN - fix this: Dom
UT_DEBUGMSG(("Saving Auto Save File [%i]\n", _gatherAutoSaveFile()));
Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_AutoSaveFile, _gatherAutoSaveFile() );
UT_String stVal;
_gatherAutoSaveFileExt(stVal);
UT_DEBUGMSG(("Saving Auto Save File Ext [%s]\n", stVal.c_str()));
pPrefsScheme->setValue(XAP_PREF_KEY_AutoSaveFileExt, stVal.c_str());
_gatherAutoSaveFilePeriod(stVal);
UT_DEBUGMSG(("Saving Auto Save File with a period of [%s]\n", stVal.c_str()));
pPrefsScheme->setValue(XAP_PREF_KEY_AutoSaveFilePeriod, stVal.c_str());
// Jordi: win32 specific for now
_gatherUILanguage(stVal);
if (stVal.length())
{
UT_DEBUGMSG(("Setting default UI language to [%s]\n", stVal.c_str()));
pPrefsScheme->setValue(AP_PREF_KEY_StringSet, stVal.c_str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If we changed whether the ruler is to be visible
// or hidden, then update the current window:
// (If we didn't change anything, leave it alone)
#if !defined(TOOLKIT_GTK) && !defined(TOOLKIT_COCOA) && !defined (TOOLKIT_WIN)
if (pFrameData && _gatherViewShowRuler() != pFrameData->m_bShowRuler )
{
pFrameData->m_bShowRuler = _gatherViewShowRuler() ;
if (!pFrameData->m_bIsFullScreen)
{
m_pFrame->toggleRuler(pFrameData->m_bShowRuler);
}
}
//.........这里部分代码省略.........