我有以下typedef
struct PolicyRuleInfo{
BearerQoSInfo stBearerQoS;
TFTInfo stTFTInfo;
PolicyRuleInfo(){};
PolicyRuleInfo( BearerQoSInfo const& qos, TFTInfo const& tft)
: stBearerQoS(qos), stTFTInfo(tft)
{ }
};
typedef map<string, PolicyRuleInfo> listOfPolicyRuleInfo;
struct IPAddressPolicyRulesInfo{
CIPAddress ipAddress;
listOfPolicyRuleInfo policyRules;
IPAddressPolicyRulesInfo(){};
IPAddressPolicyRulesInfo(CIPAddress ipaddr, string policyRuleName, PolicyRuleInfo policyRule): ipAddress(ipaddr){policyRules[policyRuleName]=policyRule;};
void addPolicycyRule(string policyRuleName, PolicyRuleInfo policyRule) { policyRules[policyRuleName]=policyRule; }
};
typedef map<string, IPAddressPolicyRulesInfo> APN2PolicyRules;
typedef map<string, APN2PolicyRules> IMSI2APNPolicyRules;
稍后在cpp:
u32 CPCRF::m_pNumPCCRulesViaCLI = 0;
listOfPolicyRuleInfo CPCRF::m_mlistOfCliConfiguredPolicyRules;
// map IMSI to PolicyRules
IMSI2APNPolicyRules CPCRF::m_mIMSI2PCRFInfo;
// Assign some default Policies (Applicable to all subscribers) , can be changed via CLI
listOfPolicyRuleInfo m_mlistOfCliConfiguredPolicyRules = boost::assign::map_list_of("PolicyRule_Internet", PolicyRuleInfo( BearerQoSInfo(9), TFTInfo()))
("PolicyRule_Voice_C", PolicyRuleInfo( BearerQoSInfo(5), TFTInfo()))
("PolicyRule_Voice_U", PolicyRuleInfo( BearerQoSInfo(1), TFTInfo()));
listOfPolicyRuleInfo::iterator it = m_mlistOfCliConfiguredPolicyRules.find("PolicyRule_Internet");
if (it != m_mlistOfCliConfiguredPolicyRules.end() )
{
IMSI2APNPolicyRules::iterator itr= m_mIMSI2PCRFInfo.find(imsi);
if (itr == m_mIMSI2PCRFInfo.end() )
{
IPAddressPolicyRulesInfo ipAddrPolicyRules(ueIPAddress, "PolicyRule_Internet", it->second);
APN2PolicyRules apn2policy["Apn_Internet"]=ipAddrPolicyRules;
m_mIMSI2PCRFInfo[imsi] = apn2policy;
我得到错误说数组'apn2policy'的大小有非整数类型'const char [13]'
之前我已将listOfPolicyRuleInfo声明为typedef列表,但是当更改为map时,我收到此错误。
感谢, PDK
答案 0 :(得分:4)
APN2PolicyRules apn2policy["Apn_Internet"]=ipAddrPolicyRules;
这一行试图声明一个APN2PolicyRules
数组,但size参数是一个字符串文字,没有任何意义。
你最有可能做的是:
APN2PolicyRules apn2policy; // create map
apn2policy["Apn_Internet"]=ipAddrPolicyRules; // set rule
答案 1 :(得分:1)
APN2PolicyRules apn2policy["Apn_Internet"]=ipAddrPolicyRules;
这是错的;你宣布了一系列"Apn_Internet"
×APN2PolicyRules
个对象,这显然是胡说八道!
您必须首先创建地图然后使用它:
APN2PolicyRules apn2policy; // (if it doesn't already exist)
apn2policy["Apn_Internet"] = ipAddrPolicyRules;
如您所见,Foo[Bar]
语法在不同的上下文中意味着不同的东西。