00001 00002 /* 00003 | Author: Michael Schmidt; 00004 | Gunnar Jehl 00005 | 00006 | ************************* SOFTWARE LICENSE AGREEMENT *********************** 00007 | This source code is published under the BSD License. 00008 | 00009 | See file 'LICENSE.txt' that comes with this distribution or 00010 | http://dbis.informatik.uni-freiburg.de/index.php?project=GCX/license.php 00011 | for the full license agreement. 00012 | 00013 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00014 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00016 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00017 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00018 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00019 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00020 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00021 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 | POSSIBILITY OF SUCH DAMAGE. 00024 | **************************************************************************** 00025 */ 00026 00035 #include "stringconstexpression.h" 00036 00037 StringConstExpression:: 00038 StringConstExpression(const char *_str):ConstExpression(et_stringconst) { 00039 // we replace special signs, namely: < -> < and > -> > 00040 ostringstream s; 00041 00042 for (unsigned i = 0; i < strlen(_str); i++) { 00043 if (_str[i] == '<') { 00044 s << "<"; 00045 } else if (_str[i] == '>') { 00046 s << ">"; 00047 } else { 00048 s << _str[i]; 00049 } 00050 } 00051 str = strdup(s.str().c_str()); 00052 delete[]_str; 00053 } 00054 00055 StringConstExpression::~StringConstExpression() { 00056 free((char *) str); 00057 } 00058 00059 void StringConstExpression::print(OutputStream & dos) const { 00060 dos << "\"" << str << "\""; 00061 } 00062 00063 void StringConstExpression::eval(OutputStream & eos, Environment * env, 00064 unsigned modus) { 00065 00066 switch (modus) { 00067 00068 case EVAL_QUERY: 00069 eos << str; 00070 break; 00071 00072 case EVAL_SIGNOFF: 00073 break; 00074 00075 default: 00076 throw 00077 RuntimeException 00078 ("StringConstExpression: Illegal Evaluation Mode", 00079 eid_runtime_illegalmode); 00080 break; 00081 } 00082 } 00083 00084 Value *StringConstExpression::getNextValue() { 00085 if (initial) { 00086 initial = false; 00087 cur_val.setStrVal(strdup(str)); 00088 return &cur_val; 00089 } else { 00090 initial = true; 00091 return NULL; 00092 } 00093 }