コード例 #1
0
boolean OCI_API OCI_ElemSetString2(OCI_Library *pOCILib, OCI_Elem *elem, const dtext *value, ExceptionSink* xsink)
{
    boolean res  = TRUE;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, FALSE);
    if (elem->typinf->cols[0].type != OCI_CDT_TEXT) {
       QoreStringNode* desc = new QoreStringNode("cannot bind a string value to element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (value == NULL)
    {
        res = OCI_ElemSetNull2(pOCILib, elem);
    }
    else
    {
        res = OCI_StringToStringPtr(pOCILib, (OCIString **) &elem->handle, 
                                    elem->con->err, (void *) value, 
                                    &elem->buf, &elem->buflen, xsink);

        OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL);
    }

    OCI_RESULT(pOCILib, res);

    return res;
}
コード例 #2
0
static const QoreStringNode* get_string_header_node(ExceptionSink* xsink, QoreHashNode& h, const char* header, bool allow_multiple = false) {
   AbstractQoreNode* n = h.getKeyValue(header);
   if (!n)
      return 0;

   qore_type_t t = get_node_type(n);
   if (t == NT_STRING)
      return reinterpret_cast<const QoreStringNode*>(n);
   assert(t == NT_LIST);
   if (!allow_multiple) {
      xsink->raiseException("HTTP-HEADER-ERROR", "multiple \"%s\" headers received in HTTP message", header);
      return 0;
   }
   // convert list to a comma-separated string
   QoreListNode* l = reinterpret_cast<QoreListNode*>(n);
   // get first list entry
   n = l->retrieve_entry(0);
   assert(get_node_type(n) == NT_STRING);
   QoreStringNode* rv = reinterpret_cast<QoreStringNode*>(n)->copy();
   for (size_t i = 1; i < l->size(); ++i) {
      n = l->retrieve_entry(i);
      assert(get_node_type(n) == NT_STRING);
      rv->concat(',');
      rv->concat(reinterpret_cast<QoreStringNode*>(n));
   }
   // dereference old list and save reference to return value in header hash
   h.setKeyValue(header, rv, xsink);
   return rv;
}
コード例 #3
0
ファイル: CallReferenceNode.cpp プロジェクト: temnoregg/qore
AbstractQoreNode* ParseObjectMethodReferenceNode::parseInitImpl(LocalVar* oflag, int pflag, int& lvids, const QoreTypeInfo*& typeInfo) {
   typeInfo = callReferenceTypeInfo;
   if (exp) {
      const QoreTypeInfo* argTypeInfo = 0;
      exp = exp->parseInit(oflag, pflag, lvids, argTypeInfo);

      if (argTypeInfo->hasType()) {
	 if (objectTypeInfo && argTypeInfo && !objectTypeInfo->parseAccepts(argTypeInfo)) {
	    // raise parse exception
	    QoreStringNode* desc = new QoreStringNode("invalid call; object expression gives ");
	    argTypeInfo->getThisType(*desc);
	    desc->concat(", but should resolve to an object to make a call with this syntax");
	    qore_program_private::makeParseException(getProgram(), "PARSE-TYPE-ERROR", desc);
	 }
	 else {
	    const QoreClass* n_qc = argTypeInfo->getUniqueReturnClass();
	    if (n_qc) {
	       bool m_priv = false;
	       m = qore_class_private::parseFindMethodTree(*const_cast<QoreClass*>(n_qc), method.c_str(), m_priv);
	       if (m) {
		  qc = n_qc;
		  if (m_priv && !qore_class_private::parseCheckPrivateClassAccess(*qc))
		     parseException("PARSE-ERROR", "method %s::%s() is private in this context, therefore a call reference cannot be taken", qc->getName(), method.c_str());
	       }
	       else
		  parseException("PARSE-ERROR", "method %s::%s() cannot be found", n_qc->getName(), method.c_str());
	    }
	 }
      }
   }
   return this;
}
コード例 #4
0
ファイル: CallStack.cpp プロジェクト: temnoregg/qore
QoreHashNode* CallNode::getInfo() const {
   QoreHashNode* h = new QoreHashNode;
   // FIXME: add class name
   QoreStringNode *str = new QoreStringNode;
   if (obj) {
      str->concat(obj.getClass()->name.c_str());
      str->concat("::");
   }
   str->concat(func);

   h->setKeyValue("function", str, 0);
   h->setKeyValue("line",     new QoreBigIntNode(loc.start_line), 0);
   h->setKeyValue("endline",  new QoreBigIntNode(loc.end_line), 0);
   h->setKeyValue("file",     new QoreStringNode(loc.file), 0);
   h->setKeyValue("source",   loc.source ? new QoreStringNode(loc.source) : 0, 0);
   h->setKeyValue("offset",   new QoreBigIntNode(loc.offset), 0);
   h->setKeyValue("typecode", new QoreBigIntNode(type), 0);
   // CT_RETHROW is only aded manually
   switch (type) {
      case CT_USER:
	 h->setKeyValue("type",  new QoreStringNode("user"), 0);
	 break;
      case CT_BUILTIN:
	 h->setKeyValue("type",  new QoreStringNode("builtin"), 0);
	 break;
      case CT_NEWTHREAD:
	 h->setKeyValue("type",  new QoreStringNode("new-thread"), 0);
	 break;
   }
   return h;
}
コード例 #5
0
void getQoreException(java::lang::Throwable *t, ExceptionSink &xsink) {
   //fprintf(stderr, "Unhandled Java exception %p:\n", t);

   //fprintf(stderr, "%s\n", str.getBuffer());

   QoreStringNode *desc = getJavaExceptionMessage(t);

   // get stack trace
   JArray<java::lang::StackTraceElement *> *stack = t->getStackTrace();
   
   java::lang::StackTraceElement **e = elements(stack);
   for (int i = 0; i < stack->length; ++i) {
      QoreString file, cls, meth;
      getQoreString(e[i]->getFileName(), file);
      getQoreString(e[i]->getClassName(), cls);
      getQoreString(e[i]->getMethodName(), meth);

      int line = e[i]->getLineNumber();

      desc->sprintf("\n  %s:%d: %s::%s() (%s)", file.getBuffer(), line > 0 ? line : 0, cls.getBuffer(), meth.getBuffer(), e[i]->isNativeMethod() ? "native" : "java");
   }

   while ((t = t->getCause())) {
      desc->concat("\ncaused by: ");
      SimpleRefHolder<QoreStringNode> ndesc(getJavaExceptionMessage(t));
      desc->concat(*ndesc, &xsink);
   }

   xsink.raiseException("JAVA-EXCEPTION", desc);
}
コード例 #6
0
const dtext * OCI_API OCI_ElemGetString2(OCI_Library *pOCILib, OCI_Elem *elem)
{
    const dtext *str  = NULL;
    boolean res       = FALSE;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);

    if (elem->typinf->cols[0].type != OCI_CDT_TEXT) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve a text value for element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }
    
    if (elem->handle != NULL)
    {
        res = TRUE;

        str = (dtext *) OCI_StringFromStringPtr(pOCILib, (OCIString *) elem->handle,
                                                &elem->buf, &elem->buflen);
    }

    OCI_RESULT(pOCILib, res);

    return str;    
}
コード例 #7
0
   // always generate a Host header pointing to the host hosting the resource, not the proxy
   // (RFC 2616 is not totally clear on this, but other clients do it this way)
   DLLLOCAL AbstractQoreNode* getHostHeaderValue() {
      if (connection.port == 80)
	 return new QoreStringNode(connection.host.c_str());

      QoreStringNode* str = new QoreStringNode;
      str->concat(connection.host);
      if (connection.port)
	 str->sprintf(":%d", connection.port);
      return str;
   }
コード例 #8
0
ファイル: StatementBlock.cpp プロジェクト: temnoregg/qore
void StatementBlock::parseCheckReturn() {
   const QoreTypeInfo* returnTypeInfo = getReturnTypeInfo();
   if (returnTypeInfo->hasType() && !returnTypeInfo->parseAccepts(nothingTypeInfo)) {
      // make sure the last statement is a return statement if the block has a return type
      if (statement_list.empty() || !(*statement_list.last())->hasFinalReturn()) {
	 QoreStringNode* desc = new QoreStringNode("this code block has declared return type ");
	 returnTypeInfo->getThisType(*desc);
	 desc->concat(" but does not have a return statement as the last statement in the block");
	 qore_program_private::makeParseException(getProgram(), loc, "MISSING-RETURN", desc);
      }
   }
}
コード例 #9
0
ファイル: QoreURL.cpp プロジェクト: qorelanguage/qore
   DLLLOCAL void reset() {
      if (protocol)
	 protocol->deref();
      if (path)
	 path->deref();
      if (username)
	 username->deref();
      if (password)
	 password->deref();
      if (host)
	 host->deref();
   }
コード例 #10
0
AbstractQoreNode *javaToQore(java::lang::String *jstr) {
   if (!jstr)
      return 0;

   QoreStringNode *str = new QoreStringNode(QCS_UTF8);

   int size = JvGetStringUTFLength(jstr);
   
   str->allocate(size + 1);
   JvGetStringUTFRegion(jstr, 0, jstr->length(), (char *)str->getBuffer());
   str->terminate(size);
   return str;
}
コード例 #11
0
ファイル: ExceptionSink.cpp プロジェクト: qorelanguage/qore
void ExceptionSink::raiseException(const QoreProgramLocation &loc, const char *err, AbstractQoreNode *arg, const char *fmt, ...) {
   QoreStringNode *desc = new QoreStringNode;

   va_list args;

   while (true) {
      va_start(args, fmt);
      int rc = desc->vsprintf(fmt, args);
      va_end(args);
      if (!rc)
         break;
   }

   raiseException(loc, err, arg, desc);
}
コード例 #12
0
ファイル: ExceptionSink.cpp プロジェクト: qorelanguage/qore
AbstractQoreNode* ExceptionSink::raiseErrnoException(const char *err, int en, const char *fmt, ...) {
   QoreStringNode *desc = new QoreStringNode;
   
   va_list args;
   
   while (true) {
      va_start(args, fmt);
      int rc = desc->vsprintf(fmt, args);
      va_end(args);
      if (!rc)
	 break;
   }

   return raiseErrnoException(err, en, desc);
}
コード例 #13
0
ファイル: QoreException.cpp プロジェクト: temnoregg/qore
// static member function
void ExceptionSink::defaultWarningHandler(QoreException *e) {
   ExceptionSink xsink;

   while (e) {
      printe("warning encountered ");

      if (!e->file.empty()) {
         printe("at %s:", e->file.c_str());
	 if (e->start_line == e->end_line) {
	    if (!e->start_line) {
	       printe("<init>");
               if (!e->source.empty())
                  printe(" (source %s)", e->source.c_str());
	    }
	    else {
	       printe("%d", e->start_line);
	       if (!e->source.empty())
	          printe(" (source %s:%d)", e->source.c_str(), e->start_line + e->offset);
	    }
	 }
	 else {
	    printe("%d-%d", e->start_line, e->end_line);
            if (!e->source.empty())
               printe(" (source %s:%d-%d)", e->source.c_str(), e->start_line + e->offset, e->end_line + e->offset);
	 }
      }
      else if (e->start_line) {
	 if (e->start_line == e->end_line) {
	    if (!e->start_line)
	       printe("at <init>");
	    else
	       printe("on line %d", e->start_line);
	 }
	 else
	    printe("on line %d-%d", e->start_line, e->end_line);
      }
      printe("\n");

      QoreStringNode* err  = reinterpret_cast<QoreStringNode*>(e->err);
      QoreStringNode* desc = reinterpret_cast<QoreStringNode*>(e->desc);

      printe("%s: %s\n", err->getBuffer(), desc->getBuffer());

      e = e->next;
      if (e)
	 printe("next warning:\n");
   }
}
コード例 #14
0
ファイル: ExceptionSink.cpp プロジェクト: qorelanguage/qore
AbstractQoreNode* ExceptionSink::raiseException(const char *err, const char *fmt, ...) {
   QoreStringNode *desc = new QoreStringNode;
   
   va_list args;
   
   while (true) {
      va_start(args, fmt);
      int rc = desc->vsprintf(fmt, args);
      va_end(args);
      if (!rc)
	 break;
   }
   printd(5, "ExceptionSink::raiseException(%s, %s)\n", err, desc->getBuffer());
   priv->insert(new QoreException(err, desc));
   return 0;
}
コード例 #15
0
QoreStringNode *getJavaExceptionMessage(java::lang::Throwable *t) {
   //printd(0, "getJavaExceptionMessage() t=%p\n", t);

   QoreStringNode *desc = new QoreStringNode;

   // get exception class name
   getQoreString(t->getClass()->getName(), *desc);

   java::lang::String *jstr = t->getMessage();
   if (jstr) {
      desc->concat(", message: ");
      appendQoreString(jstr, *desc);
   }

   return desc;
}
コード例 #16
0
/* ------------------------------------------------------------------------ *
 * OCI_ElemSetLob
 * ------------------------------------------------------------------------ */
boolean OCI_API OCI_ElemSetLob2(OCI_Library *pOCILib, OCI_Elem *elem, OCI_Lob *value, ExceptionSink* xsink)
{
    boolean res  = TRUE;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, FALSE);

    if (elem->typinf->cols[0].type != OCI_CDT_LOB) {
       QoreStringNode* desc = new QoreStringNode("cannot bind a lob value to element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }
  
    if (value == NULL)
    {
        res = OCI_ElemSetNull2(pOCILib, elem);
    }
    else
    {
        if (elem->obj == NULL)
        {
            OCI_LobInit(pOCILib, elem->con, (OCI_Lob **) &elem->obj,
                        (OCILobLocator *) elem->handle,
                        elem->typinf->cols[0].subtype, xsink);
        }

        if (elem->obj != NULL)
        {
	   res = OCI_LobAssign(pOCILib, (OCI_Lob *) elem->obj, value, xsink);

            if (res == TRUE)
            {
                OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL);

                elem->handle = ((OCI_Lob *) elem->obj)->handle;
            }
        }
    }

    OCI_RESULT(pOCILib, res);

    return res;
}
コード例 #17
0
ファイル: CallReferenceNode.cpp プロジェクト: temnoregg/qore
AbstractQoreNode* CallReferenceCallNode::parseInitImpl(LocalVar* oflag, int pflag, int& lvids, const QoreTypeInfo*& typeInfo) {
   // call references calls can return any value
   typeInfo = 0;

   pflag &= ~(PF_RETURN_VALUE_IGNORED);

   const QoreTypeInfo* expTypeInfo = 0;
   if (exp) {
      exp = exp->parseInit(oflag, pflag, lvids, expTypeInfo);

      if (expTypeInfo && codeTypeInfo && expTypeInfo->hasType() && !codeTypeInfo->parseAccepts(expTypeInfo)) {
	 // raise parse exception
	 QoreStringNode* desc = new QoreStringNode("invalid call; expression gives ");
	 expTypeInfo->getThisType(*desc);
	 desc->concat(", but a call reference or closure is required to make a call");
	 qore_program_private::makeParseException(getProgram(), "PARSE-TYPE-ERROR", desc);
      }
   }

   if (args) {
      bool needs_eval = args->needs_eval();

      // turn off PF_RETURN_VALUE_IGNORED
      pflag &= ~PF_RETURN_VALUE_IGNORED;
      
      ListIterator li(args);
      while (li.next()) {
	 AbstractQoreNode** n = li.getValuePtr();
	 if (*n) {
	    const QoreTypeInfo* argTypeInfo = 0;
	    (*n) = (*n)->parseInit(oflag, pflag, lvids, argTypeInfo);
	    
	    if (!needs_eval && (*n)->needs_eval()) {
	       args->setNeedsEval();
	       needs_eval = true;
	    }
	 }
      }
   }
   
   return this;
}
コード例 #18
0
ファイル: RegexSubstNode.cpp プロジェクト: qorelanguage/qore
// called directly for run-time evaluation
QoreStringNode *RegexSubstNode::exec(const QoreString *target, const QoreString *nstr, ExceptionSink *xsink) const {
   TempEncodingHelper t(target, QCS_UTF8, xsink);
   if (*xsink)
      return 0;

   QoreStringNode *tstr = new QoreStringNode;
   
   const char *ptr = t->getBuffer();
   //printd(5, "RegexSubstNode::exec(%s) this=%p: global=%s\n", ptr, this, global ? "true" : "false"); 
   while (true) {
      int ovector[SUBST_OVECSIZE];
      int offset = ptr - t->getBuffer();
      if ((unsigned)offset >= t->size())
         break;
      int rc = pcre_exec(p, 0, t->getBuffer(), t->strlen(), offset, 0, ovector, SUBST_OVECSIZE);

      //printd(5, "RegexSubstNode::exec() prec_exec() rc: %d\n", rc);
      // FIXME: rc = 0 means that not enough space was available in ovector!
      if (rc < 1)
	 break;
      
      if (ovector[0] > offset)
	 tstr->concat(ptr, ovector[0] - offset);
      
      concat(tstr, ovector, SUBST_LASTELEM, nstr->getBuffer(), t->getBuffer(), rc);
      
      //printd(5, "RegexSubstNode::exec() '%s' =~ s/?/%s/%s offset=%d, 0=%d, 1=%d ('%s')\n", t->getBuffer(), nstr->getBuffer(), global ? "g" : "", offset, ovector[0], ovector[1], tstr->getBuffer());
      
      ptr = t->getBuffer() + ovector[1];
      
      if (!global)
	 break;
   } 
   
   //printd(5, "RegexSubstNode::exec() *ptr=%d ('%s') tstr='%s'\n", *ptr, ptr, tstr->getBuffer());
   if (*ptr)
      tstr->concat(ptr);
   
   //printd(5, "RegexSubstNode::exec() this=%p: returning '%s'\n", this, tstr->getBuffer());
   return tstr;
}
コード例 #19
0
ファイル: RegexTransNode.cpp プロジェクト: qorelanguage/qore
QoreStringNode *RegexTransNode::exec(const QoreString *str, ExceptionSink *xsink) const {
   //printd(5, "source='%s' target='%s' ('%s')\n", source->getBuffer(), target->getBuffer(), str->getBuffer());
   TempEncodingHelper tstr(str, QCS_DEFAULT, xsink);
   if (*xsink)
      return 0;

   QoreStringNode *ns = new QoreStringNode;
   for (qore_size_t i = 0; i < tstr->strlen(); i++) {
      char c = tstr->getBuffer()[i];
      const char *p = strchr(source->getBuffer(), c);
      if (p) {
	 qore_size_t pos = p - source->getBuffer();
	 if (target->strlen() <= pos)
	    pos = target->strlen() - 1;
	 ns->concat(target->getBuffer()[pos]);
      }
      else
	 ns->concat(c);
   }

   return ns;
}
コード例 #20
0
ファイル: QoreException.cpp プロジェクト: temnoregg/qore
// static function
QoreHashNode *QoreException::getStackHash(int type, const char *class_name, const char *code, const QoreProgramLocation& loc) {
   QoreHashNode *h = new QoreHashNode;

   QoreStringNode *str = new QoreStringNode;
   if (class_name)
      str->sprintf("%s::", class_name);
   str->concat(code);

   //printd(5, "QoreException::getStackHash() %s at %s:%d-%d src: %s+%d\n", str->getBuffer(), loc.file ? loc.file : "n/a", loc.start_line, loc.end_line, loc.source ? loc.source : "n/a", loc.offset);
   
   h->setKeyValue("function", str, 0);
   h->setKeyValue("line",     new QoreBigIntNode(loc.start_line), 0);
   h->setKeyValue("endline",  new QoreBigIntNode(loc.end_line), 0);
   h->setKeyValue("file",     loc.file ? new QoreStringNode(loc.file) : 0, 0);
   h->setKeyValue("source",   loc.source ? new QoreStringNode(loc.source) : 0, 0);
   h->setKeyValue("offset",   new QoreBigIntNode(loc.offset), 0);
   h->setKeyValue("typecode", new QoreBigIntNode(type), 0);
   const char *tstr = 0;
   switch (type) {
      case CT_USER:
	 tstr = "user";
         break;
      case CT_BUILTIN:
	 tstr = "builtin";
         break;
      case CT_RETHROW:
	 tstr = "rethrow";
         break;
/*
      case CT_NEWTHREAD:
	 tstr = "new-thread";
         break;
*/
      default:
	 assert(false);
   }
   h->setKeyValue("type",  new QoreStringNode(tstr), 0);
   return h;
}
コード例 #21
0
OCI_Object * OCI_API OCI_ElemGetObject2(OCI_Library * pOCILib, OCI_Elem *elem, ExceptionSink* xsink)
{
    boolean res = TRUE;
    OCI_Object *obj = NULL;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);

    if (elem->typinf->cols[0].type != OCI_CDT_OBJECT) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve an object value from element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (elem->ind != OCI_IND_NULL)
    {
        if (elem->init == FALSE)
        {
            obj = OCI_ObjectInit(pOCILib, elem->con, (OCI_Object **) &elem->obj,
                                 elem->handle, 
                                 elem->typinf->cols[0].typinf,
                                 NULL, -1, TRUE, xsink);

            elem->init = (obj != NULL);
        }
        else
            obj = (OCI_Object *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(pOCILib, res);

    return obj;
}
コード例 #22
0
boolean OCI_ElemSetNumberFromString(OCI_Library* pOCILib, OCI_Elem* elem, const char* str, int size, ExceptionSink* xsink) {
    boolean res = FALSE;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, FALSE);
    if (elem->typinf->cols[0].type != OCI_CDT_NUMERIC) {
       QoreStringNode* desc = new QoreStringNode("cannot bind a numeric value to element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    res = OCI_NumberConvertStr2(pOCILib, elem->con, (OCINumber*)elem->handle, str, size, NUM_FMT, NUM_FMT_LEN, xsink);

    if (res)
       OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL);

    OCI_RESULT(pOCILib, res);

    return res;
}
コード例 #23
0
OCI_Timestamp * OCI_API  OCI_ElemGetTimestamp2(OCI_Library *pOCILib, OCI_Elem *elem)
{
    boolean res = TRUE;
    OCI_Timestamp *tmsp = NULL;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);

    if (elem->typinf->cols[0].type != OCI_CDT_TIMESTAMP) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve a timestamp value for element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (elem->ind != OCI_IND_NULL)
    {
        if (elem->init == FALSE)
        {
            tmsp = OCI_TimestampInit(pOCILib, elem->con, (OCI_Timestamp **) &elem->obj, 
                                     (OCIDateTime *) elem->handle, 
                                     elem->typinf->cols[0].subtype);

            elem->init = (tmsp != NULL);
        }
        else
            tmsp = (OCI_Timestamp *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(pOCILib, res);

    return tmsp;
}
コード例 #24
0
OCI_Interval * OCI_API OCI_ElemGetInterval2(OCI_Library *pOCILib, OCI_Elem *elem)
{
    boolean res = TRUE;
    OCI_Interval *itv = NULL;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);

    if (elem->typinf->cols[0].type != OCI_CDT_INTERVAL) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve an interval value for element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (elem->ind != OCI_IND_NULL)
    {
        if (elem->init == FALSE)
        {
            itv = OCI_IntervalInit(pOCILib, elem->con, (OCI_Interval **) &elem->obj, 
                                    (OCIInterval *) elem->handle,
                                    elem->typinf->cols[0].subtype);

            elem->init = (itv != NULL);
        }
        else
            itv = (OCI_Interval *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(pOCILib, res);

    return itv;
}
コード例 #25
0
OCI_Coll * OCI_API OCI_ElemGetColl2(OCI_Library *pOCILib, OCI_Elem *elem, ExceptionSink* xsink)
{
    boolean res    = TRUE;
    OCI_Coll *coll = NULL;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);

    if (elem->typinf->cols[0].type != OCI_CDT_COLLECTION) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve a collection from element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (elem->ind != OCI_IND_NULL)
    {
        if (elem->init == FALSE)
        {
            coll = OCI_CollInit(pOCILib, elem->con, (OCI_Coll **) &elem->obj, 
                                (OCIColl *) elem->handle, 
                                elem->typinf->cols[0].typinf, xsink);

            elem->init = (coll != NULL);
        }
        else
            coll = (OCI_Coll *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(pOCILib, res);

    return coll;
}
コード例 #26
0
OCI_Date * OCI_API  OCI_ElemGetDate2(OCI_Library *pOCILib, OCI_Elem *elem)
{
    boolean res    = TRUE;
    OCI_Date *date = NULL;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);

    if (elem->typinf->cols[0].type != OCI_CDT_DATETIME) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve a datetime value for element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }
    
    if (elem->ind != OCI_IND_NULL)
    {
        if (elem->init == FALSE)
        {
            date = OCI_DateInit2(pOCILib, elem->con, (OCI_Date **) &elem->obj, 
                                (OCIDate *) elem->handle, FALSE, FALSE);

            elem->init = (date != NULL);
        }
        else
            date = (OCI_Date *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(pOCILib, res);

    return date;
}
コード例 #27
0
AbstractQoreNode* QoreAssignmentOperatorNode::parseInitImpl(LocalVar* oflag, int pflag, int& lvids, const QoreTypeInfo*& typeInfo) {
   // turn off "reference ok" and "return value ignored" flags
   pflag &= ~(PF_RETURN_VALUE_IGNORED);

   left = left->parseInit(oflag, pflag | PF_FOR_ASSIGNMENT, lvids, ti);
   //printd(5, "QoreAssignmentOperatorNode::parseInitImpl() this: %p left: %p '%s' nt: %d ti: %p '%s'\n", this, left, get_type_name(left), get_node_type(left), ti, ti->getName());
   checkLValue(left, pflag);

   // return type info is the same as the lvalue's typeinfo
   typeInfo = ti;

   const QoreTypeInfo* r = 0;
   right = right->parseInit(oflag, pflag, lvids, r);

   // check for illegal assignment to $self
   if (oflag)
      check_self_assignment(left, oflag);

   //printd(5, "QoreAssignmentOperatorNode::parseInitImpl() this: %p left: %s ti: %p '%s', right: %s ti: %s\n", this, get_type_name(left), ti, ti->getName(), get_type_name(right), r->getName());

   if (ti->hasType() && r->hasType() && !ti->parseAccepts(r)) {
      if (getProgram()->getParseExceptionSink()) {
	 QoreStringNode *edesc = new QoreStringNode("lvalue for assignment operator (=) expects ");
	 ti->getThisType(*edesc);
	 edesc->concat(", but right-hand side is ");
	 r->getThisType(*edesc);
	 qore_program_private::makeParseException(getProgram(), loc, "PARSE-TYPE-ERROR", edesc);
      }
   }

   // replace this node with optimized operator implementations, if possible
   if (ti == bigIntTypeInfo || ti == softBigIntTypeInfo)
      return makeSpecialization<QoreIntAssignmentOperatorNode>();

   return this;
}
コード例 #28
0
OCI_Lob * OCI_API OCI_ElemGetLob2(OCI_Library *pOCILib, OCI_Elem *elem, ExceptionSink* xsink)
{
    boolean res  = TRUE;
    OCI_Lob *lob = NULL;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);
    if (elem->typinf->cols[0].type != OCI_CDT_LOB) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve a LOB value from element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (elem->ind != OCI_IND_NULL)
    {      
        if (elem->init == FALSE)
        {
            lob = OCI_LobInit(pOCILib, elem->con, (OCI_Lob **) &elem->obj, 
                              (OCILobLocator *) elem->handle,
                              elem->typinf->cols[0].subtype, xsink);

            elem->init = (lob != NULL);
        }
        else
            lob = (OCI_Lob *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(pOCILib, res);

    return lob;
}
コード例 #29
0
AbstractQoreNode *javaToQore(jchar c) {
   QoreStringNode *str = new QoreStringNode(QCS_UTF8);
   str->concatUTF8FromUnicode(c);
   return str;
}
コード例 #30
0
ファイル: QoreURL.cpp プロジェクト: qorelanguage/qore
 DLLLOCAL bool isValid() const {
    return (host && host->strlen()) || (path && path->strlen());
 }