コード例 #1
0
ファイル: main.cpp プロジェクト: SirFurness/AttributeParser
string getTagAttributeValue(Tag tag, string wantedAttributeName) {
    
    int location = 0;
    
    for(int i = 0; i < tag.getAttributeName().size(); i++) {
        if(tag.getAttributeName()[i] == wantedAttributeName) {
            location = i;
        }
    }
    
    return tag.getAttributeValue()[location];
    
}
コード例 #2
0
ファイル: main.cpp プロジェクト: SirFurness/AttributeParser
string processQuery(string query, const vector<Tag> &tags, bool isNested) {
    
    string wantedTagName = getWantedTagName(query);
    string wantedAttributeName = getWantedAttributeName(query);
    Tag tag = getWantedTag(tags, wantedTagName);
    
    if(tagHasAttribute(tag.getAttributeName(), wantedAttributeName)) {
        
        string attributeValue = getTagAttributeValue(tag, wantedAttributeName);
        
        vector<string> nested = tag.getNested();
        
        if((nested.size() == 0 && !isNested) || (nested.size() > 0 && isNested)) {
            return attributeValue;
        }
        else {
            return "Not Found!";
        }
        
    }
    else {
        return "Not Found!";
    }
    
    
    
}