Go to the documentation of this file.00001 #include <actasp/AspAtom.h>
00002
00003 using namespace std;
00004
00005 namespace actasp {
00006
00007 AspAtom::AspAtom(const std::string& formula) throw () :atom(formula) {}
00008
00009
00010 unsigned int AspAtom::arity() const throw() {
00011 return getParameters().size();
00012 }
00013
00014 std::string AspAtom::getName() const throw() {
00015 return atom.substr(0,atom.find_first_of('('));
00016 }
00017
00018 std::vector<std::string> AspAtom::getParameters() const throw() {
00019
00020 size_t start = atom.find_first_of('(')+1;
00021 size_t end = atom.find_last_of(')');
00022
00023 vector<string> params;
00024
00025 if(start >= end)
00026 return params;
00027
00028 size_t comma = atom.find_first_of(',',start);
00029 size_t end_param = std::min(comma,end);
00030
00031 while(start < end) {
00032 params.push_back(atom.substr(start,end_param-start));
00033 start = end_param+1;
00034 end_param = std::min(atom.find_first_of(',',start),end);
00035 }
00036
00037 return params;
00038 }
00039
00040
00041 }