本文整理汇总了C++中QTSSDictionaryMap::IsRemoved方法的典型用法代码示例。如果您正苦于以下问题:C++ QTSSDictionaryMap::IsRemoved方法的具体用法?C++ QTSSDictionaryMap::IsRemoved怎么用?C++ QTSSDictionaryMap::IsRemoved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTSSDictionaryMap
的用法示例。
在下文中一共展示了QTSSDictionaryMap::IsRemoved方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateObjectValue
QTSS_Error QTSSDictionary::CreateObjectValue(QTSS_AttributeID inAttrID, UInt32* outIndex,
QTSSDictionary** newObject, QTSSDictionaryMap* inMap, UInt32 inFlags)
{
// Check first to see if this is a static attribute or an instance attribute
QTSSDictionaryMap* theMap = fMap;
DictValueElement* theAttrs = fAttributes;
if (QTSSDictionaryMap::IsInstanceAttrID(inAttrID))
{
theMap = fInstanceMap;
theAttrs = fInstanceAttrs;
}
if (theMap == NULL)
return QTSS_AttrDoesntExist;
SInt32 theMapIndex = theMap->ConvertAttrIDToArrayIndex(inAttrID);
// If there is a mutex, make this action atomic.
OSMutexLocker locker(fMutexP);
if (theMapIndex < 0)
return QTSS_AttrDoesntExist;
if ((!(inFlags & kDontObeyReadOnly)) && (!theMap->IsWriteable(theMapIndex)))
return QTSS_ReadOnly;
if (theMap->IsRemoved(theMapIndex))
return QTSS_AttrDoesntExist;
if (theMap->GetAttrType(theMapIndex) != qtssAttrDataTypeQTSS_Object)
return QTSS_BadArgument;
UInt32 numValues = theAttrs[theMapIndex].fNumAttributes;
// if normal QTSSObjects have been added, then we can't add a dynamic one
if (!theAttrs[theMapIndex].fIsDynamicDictionary && (numValues > 0))
return QTSS_ReadOnly;
QTSSDictionary* oldDict = NULL;
*outIndex = numValues; // add the object into the next spot
UInt32 len = sizeof(QTSSDictionary*);
QTSSDictionary* dict = CreateNewDictionary(inMap, fMutexP);
// kind of a hack to avoid the check in SetValue
theAttrs[theMapIndex].fIsDynamicDictionary = false;
QTSS_Error err = SetValue(inAttrID, *outIndex, &dict, len, inFlags);
if (err != QTSS_NoErr)
{
delete dict;
return err;
}
if (oldDict != NULL)
{
delete oldDict;
}
theAttrs[theMapIndex].fIsDynamicDictionary = true;
*newObject = dict;
return QTSS_NoErr;
}
示例2: GetValuePtr
QTSS_Error QTSSDictionary::GetValuePtr(QTSS_AttributeID inAttrID, UInt32 inIndex,
void** outValueBuffer, UInt32* outValueLen,
Bool16 isInternal)
{
// Check first to see if this is a static attribute or an instance attribute
QTSSDictionaryMap* theMap = fMap;
DictValueElement* theAttrs = fAttributes;
if (QTSSDictionaryMap::IsInstanceAttrID(inAttrID))
{
theMap = fInstanceMap;
theAttrs = fInstanceAttrs;
}
if (theMap == NULL)
return QTSS_AttrDoesntExist;
SInt32 theMapIndex = theMap->ConvertAttrIDToArrayIndex(inAttrID);
if (theMapIndex < 0)
return QTSS_AttrDoesntExist;
if (theMap->IsRemoved(theMapIndex))
return QTSS_AttrDoesntExist;
if ((!isInternal) && (!theMap->IsPreemptiveSafe(theMapIndex)) && !this->IsLocked())
return QTSS_NotPreemptiveSafe;
// An iterated attribute cannot have a param retrieval function
if ((inIndex > 0) && (theMap->GetAttrFunction(theMapIndex) != NULL))
return QTSS_BadIndex;
// Check to make sure the index parameter is legal
if ((inIndex > 0) && (inIndex >= theAttrs[theMapIndex].fNumAttributes))
return QTSS_BadIndex;
// Retrieve the parameter
char* theBuffer = theAttrs[theMapIndex].fAttributeData.Ptr;
*outValueLen = theAttrs[theMapIndex].fAttributeData.Len;
Bool16 cacheable = theMap->IsCacheable(theMapIndex);
if ( (theMap->GetAttrFunction(theMapIndex) != NULL) && ((cacheable && (*outValueLen == 0)) || !cacheable) )
{
// If function is cacheable:
// If the parameter doesn't have a value assigned yet, and there is an attribute
// retrieval function provided, invoke that function now.
// If function is *not* cacheable:
// always call the function
theBuffer = (char*)theMap->GetAttrFunction(theMapIndex)(this, outValueLen);
//If the param retrieval function didn't return an explicit value for this attribute,
//refetch the parameter out of the array, in case the function modified it.
if (theBuffer == NULL)
{
theBuffer = theAttrs[theMapIndex].fAttributeData.Ptr;
*outValueLen = theAttrs[theMapIndex].fAttributeData.Len;
}
}
#if DEBUG
else
// Make sure we aren't outside the bounds of attribute memory
Assert(theAttrs[theMapIndex].fAllocatedLen >=
(theAttrs[theMapIndex].fAttributeData.Len * (theAttrs[theMapIndex].fNumAttributes)));
#endif
// Return an error if there is no data for this attribute
if (*outValueLen == 0)
return QTSS_ValueNotFound;
theBuffer += theAttrs[theMapIndex].fAttributeData.Len * inIndex;
*outValueBuffer = theBuffer;
// strings need an extra dereference - moved it up
if ((theMap->GetAttrType(theMapIndex) == qtssAttrDataTypeCharArray) && (theAttrs[theMapIndex].fNumAttributes > 1))
{
char** string = (char**)theBuffer;
*outValueBuffer = *string;
//*outValueLen = strlen(*string) + 1;
*outValueLen = strlen(*string);
}
return QTSS_NoErr;
}
示例3: SetValue
QTSS_Error QTSSDictionary::SetValue(QTSS_AttributeID inAttrID, UInt32 inIndex,
const void* inBuffer, UInt32 inLen,
UInt32 inFlags)
{
// Check first to see if this is a static attribute or an instance attribute
QTSSDictionaryMap* theMap = fMap;
DictValueElement* theAttrs = fAttributes;
if (QTSSDictionaryMap::IsInstanceAttrID(inAttrID))
{
theMap = fInstanceMap;
theAttrs = fInstanceAttrs;
}
if (theMap == NULL)
return QTSS_AttrDoesntExist;
SInt32 theMapIndex = theMap->ConvertAttrIDToArrayIndex(inAttrID);
// If there is a mutex, make this action atomic.
OSMutexLocker locker(fMutexP);
if (theMapIndex < 0)
return QTSS_AttrDoesntExist;
if ((!(inFlags & kDontObeyReadOnly)) && (!theMap->IsWriteable(theMapIndex)))
return QTSS_ReadOnly;
if (theMap->IsRemoved(theMapIndex))
return QTSS_AttrDoesntExist;
if (theAttrs[theMapIndex].fIsDynamicDictionary)
return QTSS_ReadOnly;
UInt32 numValues = theAttrs[theMapIndex].fNumAttributes;
QTSS_AttrDataType dataType = theMap->GetAttrType(theMapIndex);
UInt32 attrLen = inLen;
if (dataType == qtssAttrDataTypeCharArray)
{
if (inIndex > 0)
attrLen = sizeof(char*); // value just contains a pointer
if ((numValues == 1) && (inIndex == 1))
{
// we're adding a second value, so we need to change the storage from directly
// storing the string to an array of string pointers
// creating new memory here just to create a null terminated string
// instead of directly using the old storage as the old storage didn't
// have its string null terminated
UInt32 tempStringLen = theAttrs[theMapIndex].fAttributeData.Len;
char* temp = NEW char[tempStringLen + 1];
::memcpy(temp, theAttrs[theMapIndex].fAttributeData.Ptr, tempStringLen);
temp[tempStringLen] = '\0';
delete [] theAttrs[theMapIndex].fAttributeData.Ptr;
//char* temp = theAttrs[theMapIndex].fAttributeData.Ptr;
theAttrs[theMapIndex].fAllocatedLen = 16 * sizeof(char*);
theAttrs[theMapIndex].fAttributeData.Ptr = NEW char[theAttrs[theMapIndex].fAllocatedLen];
theAttrs[theMapIndex].fAttributeData.Len = sizeof(char*);
// store off original string as first value in array
*(char**)theAttrs[theMapIndex].fAttributeData.Ptr = temp;
// question: why isn't theAttrs[theMapIndex].fAllocatedInternally set to true?
theAttrs[theMapIndex].fAllocatedInternally = true;
}
}