Back to index

nordugrid-arc-nox  1.1.0~rc6
EqualFunction.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include "EqualFunction.h"
00006 #include "../attr/BooleanAttribute.h"
00007 #include "../attr/StringAttribute.h"
00008 #include "../attr/DateTimeAttribute.h"
00009 #include "../attr/X500NameAttribute.h"
00010 #include "../attr/AnyURIAttribute.h"
00011 
00012 namespace ArcSec {
00013 
00014 std::string EqualFunction::getFunctionName(std::string datatype){
00015   std::string ret;
00016   if (datatype ==  StringAttribute::getIdentifier()) ret = NAME_STRING_EQUAL;
00017   else if(datatype == BooleanAttribute::getIdentifier()) ret = NAME_BOOLEAN_EQUAL;
00018   //else if(datatype == IntegerAttribute::getIdentify()) ret = NAME_INTEGER_EQUAL;
00019   //else if(datatype == DoubleAttribute::getIdentify()) ret = NAME_DOUBLE_EQUAL;
00020   else if(datatype == DateAttribute::getIdentifier()) ret = NAME_DATE_EQUAL;
00021   else if(datatype == TimeAttribute::getIdentifier()) ret = NAME_TIME_EQUAL;
00022   else if(datatype == DateTimeAttribute::getIdentifier()) ret = NAME_DATETIME_EQUAL;
00023   else if(datatype == DurationAttribute::getIdentifier()) ret = NAME_DURATION_EQUAL;
00024   else if(datatype == PeriodAttribute::getIdentifier()) ret = NAME_PERIOD_EQUAL; 
00025   //else if(datatype == DayTimeDurationAttribute::getIdentify()) ret = NAME_DAYTIME_DURATION_EQUAL;
00026   //else if(datatype == YearMonthDurationAttribute::getIdentify()) ret = NAME_YEARMONTH_DURATION_EQUAL;
00027   else if(datatype == AnyURIAttribute::getIdentifier()) ret = NAME_ANYURI_EQUAL;
00028   else if(datatype == X500NameAttribute::getIdentifier()) ret = NAME_X500NAME_EQUAL;
00029   //else if(datatype == RFC822NameAttribute::getIdentify()) ret = NAME_RFC822NAME_EQUAL;
00030   //else if(datatype == HexBinaryAttribute::getIdentify()) ret = NAME_HEXBINARY_EQUAL;
00031   //else if(datatype == Base64BinaryAttribute::getIdentify()) ret = BASE64BINARY_EQUAL;
00032   //else if(datatype == IPAddressAttribute::getIdentify()) ret = NAME_IPADDRESS_EQUAL;
00033   //else if(datatype == DNSName::getIdentify()) ret = NAME_DNSNAME_EQUAL;
00034   return ret;
00035 }
00036 
00037 EqualFunction::EqualFunction(std::string functionName, std::string argumentType) : Function(functionName, argumentType) {
00038   fnName = functionName;
00039   argType = argumentType;
00040 }
00041 
00042 AttributeValue* EqualFunction::evaluate(AttributeValue* arg0, AttributeValue* arg1, bool check_id){
00043   //TODO
00044   return new BooleanAttribute(arg0->equal(arg1, check_id));
00045 }
00046 
00047 std::list<AttributeValue*> EqualFunction::evaluate(std::list<AttributeValue*> args, bool check_id) {
00048   AttributeValue* arg0 = NULL;
00049   AttributeValue* arg1 = NULL;
00050   std::list<AttributeValue*>::iterator it = args.begin();
00051   arg0 = *it; it++;
00052   if(it!= args.end()) arg1 = *it;
00053   AttributeValue* res = new BooleanAttribute(arg0->equal(arg1, check_id));
00054   std::list<AttributeValue*> ret;
00055   ret.push_back(res);
00056   return ret;
00057 }
00058 }