本文整理汇总了C++中QTSSDictionaryMap::GetNumAttrs方法的典型用法代码示例。如果您正苦于以下问题:C++ QTSSDictionaryMap::GetNumAttrs方法的具体用法?C++ QTSSDictionaryMap::GetNumAttrs怎么用?C++ QTSSDictionaryMap::GetNumAttrs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTSSDictionaryMap
的用法示例。
在下文中一共展示了QTSSDictionaryMap::GetNumAttrs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RereadServerPreferences
void QTSServerPrefs::RereadServerPreferences(Bool16 inWriteMissingPrefs)
{
OSMutexLocker locker(&fPrefsMutex);
QTSSDictionaryMap* theMap = QTSSDictionaryMap::GetMap(QTSSDictionaryMap::kPrefsDictIndex);
for (UInt32 x = 0; x < theMap->GetNumAttrs(); x++)
{
//
// Look for a pref in the file that matches each pref in the dictionary
char* thePrefTypeStr = NULL;
char* thePrefName = NULL;
ContainerRef server = fPrefsSource->GetRefForServer();
ContainerRef pref = fPrefsSource->GetPrefRefByName( server, theMap->GetAttrName(x) );
char* thePrefValue = NULL;
if (pref != NULL)
thePrefValue = fPrefsSource->GetPrefValueByRef( pref, 0, &thePrefName,
(char**)&thePrefTypeStr);
if ((thePrefValue == NULL) && (x < qtssPrefsNumParams)) // Only generate errors for server prefs
{
//
// There is no pref, use the default and log an error
if (::strlen(sPrefInfo[x].fDefaultValue) > 0)
{
//
// Only log this as an error if there is a default (an empty string
// doesn't count). If there is no default, we will constantly print
// out an error message...
QTSSModuleUtils::LogError( QTSSModuleUtils::GetMisingPrefLogVerbosity(),
qtssServerPrefMissing,
0,
sAttributes[x].fAttrName,
sPrefInfo[x].fDefaultValue);
}
this->SetPrefValue(x, 0, sPrefInfo[x].fDefaultValue, sAttributes[x].fAttrDataType);
if (sPrefInfo[x].fAdditionalDefVals != NULL)
{
//
// Add additional default values if they exist
for (UInt32 y = 0; sPrefInfo[x].fAdditionalDefVals[y] != NULL; y++)
this->SetPrefValue(x, y+1, sPrefInfo[x].fAdditionalDefVals[y], sAttributes[x].fAttrDataType);
}
if (inWriteMissingPrefs)
{
//
// Add this value into the file, cuz we need it.
pref = fPrefsSource->AddPref( server, sAttributes[x].fAttrName, QTSSDataConverter::TypeToTypeString(sAttributes[x].fAttrDataType));
fPrefsSource->AddPrefValue(pref, sPrefInfo[x].fDefaultValue);
if (sPrefInfo[x].fAdditionalDefVals != NULL)
{
for (UInt32 a = 0; sPrefInfo[x].fAdditionalDefVals[a] != NULL; a++)
fPrefsSource->AddPrefValue(pref, sPrefInfo[x].fAdditionalDefVals[a]);
}
}
continue;
}
QTSS_AttrDataType theType = QTSSDataConverter::TypeStringToType(thePrefTypeStr);
if ((x < qtssPrefsNumParams) && (theType != sAttributes[x].fAttrDataType)) // Only generate errors for server prefs
{
//
// The pref in the file has the wrong type, use the default and log an error
if (::strlen(sPrefInfo[x].fDefaultValue) > 0)
{
//
// Only log this as an error if there is a default (an empty string
// doesn't count). If there is no default, we will constantly print
// out an error message...
QTSSModuleUtils::LogError( qtssWarningVerbosity,
qtssServerPrefWrongType,
0,
sAttributes[x].fAttrName,
sPrefInfo[x].fDefaultValue);
}
this->SetPrefValue(x, 0, sPrefInfo[x].fDefaultValue, sAttributes[x].fAttrDataType);
if (sPrefInfo[x].fAdditionalDefVals != NULL)
{
//
// Add additional default values if they exist
for (UInt32 z = 0; sPrefInfo[x].fAdditionalDefVals[z] != NULL; z++)
this->SetPrefValue(x, z+1, sPrefInfo[x].fAdditionalDefVals[z], sAttributes[x].fAttrDataType);
}
if (inWriteMissingPrefs)
{
//
// Remove it out of the file and add in the default.
fPrefsSource->RemovePref(pref);
pref = fPrefsSource->AddPref( server, sAttributes[x].fAttrName, QTSSDataConverter::TypeToTypeString(sAttributes[x].fAttrDataType));
fPrefsSource->AddPrefValue(pref, sPrefInfo[x].fDefaultValue);
if (sPrefInfo[x].fAdditionalDefVals != NULL)
{
for (UInt32 b = 0; sPrefInfo[x].fAdditionalDefVals[b] != NULL; b++)
//.........这里部分代码省略.........
示例2: RereadServerPreferences
/*这是本类最重要的函数:先遍历服务器的属性列表,逐个用预设值文件设置各指定的属性,若预设值出错,就用默认值代替,然后设置认证格式,
RTP/RTCP包头打印选项,日志写关闭,最后将调整后的预设值内容写入xml预设值文件 */
void QTSServerPrefs::RereadServerPreferences(Bool16 inWriteMissingPrefs)
{
OSMutexLocker locker(&fPrefsMutex);
//得到服务器预设值字典对象
QTSSDictionaryMap* theMap = QTSSDictionaryMap::GetMap(QTSSDictionaryMap::kPrefsDictIndex);
//遍历服务器的属性列表,逐个用预设值文件设置该指定的属性
for (UInt32 x = 0; x < theMap->GetNumAttrs(); x++)
{
// Look for a pref in the file that matches each pref in the dictionary
char* thePrefTypeStr = NULL;
char* thePrefName = NULL;
char* thePrefValue = NULL;
ContainerRef server = fPrefsSource->GetRefForServer();/* 在fRootTag下获取子Tag SERVER并返回,没有就生成它 */
ContainerRef pref = fPrefsSource->GetPrefRefByName( server, theMap->GetAttrName(x) );/* 得到子Tag SERVER指定属性名的子Tag */
/* 假如不空,返回指定Tag的指定index的子Tag的value,得到指定Tag的NAME和TYPE属性值,对Tag的情况作了分析 */
if (pref != NULL)
thePrefValue = fPrefsSource->GetPrefValueByRef( pref, 0, &thePrefName,(char**)&thePrefTypeStr);
/* 假如得到的属性值是空的, */
if ((thePrefValue == NULL) && (x < qtssPrefsNumParams)) // Only generate errors for server prefs
{
// 假如没有设置值,但有默认值,使用默认值,并在日志中记录
// There is no pref, use the default and log an error
if (::strlen(sPrefInfo[x].fDefaultValue) > 0)
{
// 假如有默认值(空字符串不算),仅在日志中记录;假如没有默认值,在屏幕上打印出来
// Only log this as an error if there is a default (an empty string
// doesn't count). If there is no default, we will constantly print
// out an error message...
QTSSModuleUtils::LogError( QTSSModuleUtils::GetMisingPrefLogVerbosity(),
qtssServerPrefMissing,
0,
sAttributes[x].fAttrName,
sPrefInfo[x].fDefaultValue);
}
//用默认值设置相应的服务器属性值
this->SetPrefValue(x, 0, sPrefInfo[x].fDefaultValue, sAttributes[x].fAttrDataType);
//假如还有附加的默认值,也要依次设置上
if (sPrefInfo[x].fAdditionalDefVals != NULL)
{
// Add additional default values if they exist
for (UInt32 y = 0; sPrefInfo[x].fAdditionalDefVals[y] != NULL; y++)
this->SetPrefValue(x, y+1, sPrefInfo[x].fAdditionalDefVals[y], sAttributes[x].fAttrDataType);
}
//假如第2个入参为true,生成指定属性值和数据类型的Tag,加入Tag内嵌队列中,并返回该Tag,即将该属性及其(多个)属性值,补充写入xml预配置文件
if (inWriteMissingPrefs)
{
// Add this value into the file, because we need it.
pref = fPrefsSource->AddPref( server, sAttributes[x].fAttrName, QTSSDataConverter::TypeToTypeString(sAttributes[x].fAttrDataType));
// 再写入指定的属性值
fPrefsSource->AddPrefValue(pref, sPrefInfo[x].fDefaultValue);
//如果有多重值,也一并写入
if (sPrefInfo[x].fAdditionalDefVals != NULL)
{
for (UInt32 a = 0; sPrefInfo[x].fAdditionalDefVals[a] != NULL; a++)
fPrefsSource->AddPrefValue(pref, sPrefInfo[x].fAdditionalDefVals[a]);
}
}
continue; //跳到下一个索引
}
QTSS_AttrDataType theType = QTSSDataConverter::TypeStringToType(thePrefTypeStr);
// 假如有预设值,但是数据类型不对,使用默认值,并记录错误
// The pref in the file has the wrong type, use the default and log an error
if ((x < qtssPrefsNumParams) && (theType != sAttributes[x].fAttrDataType)) // Only generate errors for server prefs
{
// 假如有默认值(空字符串不算),仅在日志中记录;假如没有默认值,在屏幕上打印出来
if (::strlen(sPrefInfo[x].fDefaultValue) > 0)
{
// Only log this as an error if there is a default (an empty string
// doesn't count). If there is no default, we will constantly print
// out an error message...
QTSSModuleUtils::LogError( qtssWarningVerbosity,
qtssServerPrefWrongType,
0,
sAttributes[x].fAttrName,
sPrefInfo[x].fDefaultValue);
}
//用默认值设置相应的服务器属性值
this->SetPrefValue(x, 0, sPrefInfo[x].fDefaultValue, sAttributes[x].fAttrDataType);
//假如还有附加的默认值,也要依次设置上
if (sPrefInfo[x].fAdditionalDefVals != NULL)
{
// Add additional default values if they exist
for (UInt32 z = 0; sPrefInfo[x].fAdditionalDefVals[z] != NULL; z++)
this->SetPrefValue(x, z+1, sPrefInfo[x].fAdditionalDefVals[z], sAttributes[x].fAttrDataType);
}
//假如第2个入参为true,先删除该Tag,再增加新的Tag,设置其属性,及其(多个)属性值
// Remove it out of the file and add in the default.
if (inWriteMissingPrefs)
{
fPrefsSource->RemovePref(pref);
//.........这里部分代码省略.........