00001 /* 00002 * CrocoPat is a tool for relational programming. 00003 * This file is part of CrocoPat. 00004 * 00005 * Copyright (C) 2002-2008 Dirk Beyer 00006 * 00007 * CrocoPat is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License 00009 * as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * CrocoPat is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with CrocoPat; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * Please find the GNU Lesser General Public License in file 00022 * License_LGPL.txt or at http://www.gnu.org/licenses/lgpl.txt 00023 * 00024 * Author: 00025 * Dirk Beyer (firstname.lastname@sfu.ca) 00026 * Simon Fraser University 00027 * 00028 * With contributions of: Andreas Noack, Michael Vogel 00029 */ 00030 00031 #include "relStrExpr.h" 00032 #include "relExpression.h" 00033 00035 relStrExprElem::~relStrExprElem() 00036 { 00037 delete mExpr; 00038 } 00039 00040 relString 00041 relStrExprElem::interpret(bddSymTab* pSymTab) 00042 { 00043 bddRelation lRel = mExpr->interpret(pSymTab); 00044 const set<string> lFree = mExpr->collectFreeAttrs(); 00045 if(lFree.size() != 1) { 00046 cerr << "Error: ELEMENT requires expression with one free attribute (i.e. a set)." 00047 << endl; 00048 exit(EXIT_FAILURE); 00049 } 00050 const unsigned lVarId = pSymTab->getAttributePos(*lFree.begin()); 00051 if (lRel.isEmpty()) { 00052 cerr << "Error: ELEMENT applied to empty set." << endl; 00053 exit(EXIT_FAILURE); 00054 } 00055 return relString( lRel.getElement(lVarId) ); 00056 }
1.5.1