wxString PropertyValue;
wxString PropertyTokens;
bool FirstToken = TRUE;
+ bool PropertyMatched = FALSE;
int intSplitsFound = 0;
int intSplitSize = 0;
int intPrevValue = 8;
CaptureString(&PropertyValue, FALSE);
- if (PropertyName == wxT("ALTID")){
-
- SourceListAltID.erase(*SourceCount);
- SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
+ ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
+ ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
- } else if (PropertyName == wxT("PID")){
-
- SourceListPID.erase(*SourceCount);
- SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
+ if (PropertyMatched == TRUE){
- } else if (PropertyName == wxT("PREF")){
-
- ProcessIntegerValue(&SourceListPref, &PropertyValue, SourceCount);
-
- } else if (PropertyName == wxT("MEDIATYPE")){
+ PropertyMatched = FALSE;
+ continue;
- SourceListMediatype.erase(*SourceCount);
- SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
-
- } else {
+ }
- // Something else we don't know about so append
- // to the tokens variable.
-
- if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
+ if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
- if (FirstToken == TRUE){
-
- PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
- FirstToken = FALSE;
-
- } else {
-
- PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+ if (FirstToken == TRUE){
- }
+ PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+ FirstToken = FALSE;
+
+ } else {
+
+ PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
}
wxString PropertyNameMatch,
std::map<int,wxString> *MapPtr,
wxString *PropertyValue,
- int *ItemCount){
-
+ int *ItemCount,
+ bool *PropertyMatched){
+
if (*PropertyName == PropertyNameMatch){
MapPtr->erase(*ItemCount);
MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
+ *PropertyMatched = TRUE;
}
}
+void ProcessIntegerValue(wxString *PropertyName,
+ wxString PropertyNameMatch,
+ std::map<int,int> *PrefPtr,
+ wxString *PropertyValue,
+ int *ItemCount,
+ bool *PropertyMatched){
+
+ if (*PropertyName == PropertyNameMatch){
+ *PropertyMatched = TRUE;
+ } else {
+ return;
+ }
+
+ int PriorityNumber = 0;
+ bool ValidNumber = TRUE;
+
+ try{
+ PriorityNumber = std::stoi(PropertyValue->ToStdString());
+ }
+
+ catch(std::invalid_argument &e){
+ ValidNumber = FALSE;
+ }
+
+ if (ValidNumber == TRUE){
+
+ PrefPtr->erase(*ItemCount);
+ PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
+
+ }
+
+}
+
void ProcessIntegerValue(std::map<int,int> *PrefPtr,
wxString *PropertyValue,
int *ItemCount){
int *intPrevValue,
PropertyType *intType);
+void ProcessIntegerValue(wxString *PropertyName,
+ wxString PropertyNameMatch,
+ std::map<int,int> *PrefPtr,
+ wxString *PropertyValue,
+ int *ItemCount,
+ bool *PropertyMatched);
+
void ProcessIntegerValue(std::map<int,int> *PrefPtr,
wxString *PropertyValue,
int *ItemCount);
wxString PropertyNameMatch,
std::map<int,wxString> *MapPtr,
wxString *PropertyValue,
- int *ItemCount);
+ int *ItemCount,
+ bool *PropertyMatched);
#endif
\ No newline at end of file