コード例 #1
0
ファイル: Object.test.cpp プロジェクト: CFQuantum/CFQuantumd
 void testFailureArray()
 {
     {
         setup ("array failure append");
         auto& root = makeRoot();
         auto array = root.setArray ("array");
         auto subarray = array.appendArray ();
         auto fail = [&]() { array.append ("fail"); };
         expectException (fail);
     }
     {
         setup ("array failure appendArray");
         auto& root = makeRoot();
         auto array = root.setArray ("array");
         auto subarray = array.appendArray ();
         auto fail = [&]() { array.appendArray (); };
         expectException (fail);
     }
     {
         setup ("array failure appendObject");
         auto& root = makeRoot();
         auto array = root.setArray ("array");
         auto subarray = array.appendArray ();
         auto fail = [&]() { array.appendObject (); };
         expectException (fail);
     }
 }
コード例 #2
0
ファイル: queryOperation.c プロジェクト: zaneb/sblim-sfcb
PredicateConjunction *orGetPredicateConjunction(QLOperation *op) 
{
   int rdn=0,i,m,ii,mi;
   PredicateConjunction *lc=op->lhon->ft->getPredicateConjunction(op->lhon);
   if (!op->rhon) return lc;
   
   PredicateConjunction *rc=op->rhon->ft->getPredicateConjunction(op->rhon);
   PredicateConjunction *rd=TrackedCMPIArray(
      CMGetArrayCount(lc,NULL)*CMGetArrayCount(rc,NULL), CMPI_ptr, NULL);
      
   for (i=0, m=CMGetArrayCount(lc,NULL); i<m; i++) {
      PredicateConjunction *lci=CMGetArrayElementAt(lc,i,NULL).value.dataPtr.ptr;
      for (ii=0, mi=CMGetArrayCount(rc,NULL); ii<mi; ii++) {
         PredicateConjunction *rcii=CMGetArrayElementAt(rc,ii,NULL).value.dataPtr.ptr;
         Predicates *tc=TrackedCMPIArray(0, CMPI_ptr, NULL);
         CMPIValuePtr rdv={tc,1};               
         appendArray(tc,lci);
         appendArray(tc,rcii);
         CMSetArrayElementAt(rd,rdn,&rdv,CMPI_ptr); 
         rdn++;
      }
   }
   
   return rd;
}
コード例 #3
0
ファイル: Object.cpp プロジェクト: ripple/rippled
void Array::append (Json::Value const& v)
{
    auto t = v.type();
    switch (t)
    {
    case Json::nullValue:
        return append (nullptr);
    case Json::intValue:
        return append (v.asInt());
    case Json::uintValue:
        return append (v.asUInt());
    case Json::realValue:
        return append (v.asDouble());
    case Json::stringValue:
        return append (v.asString());
    case Json::booleanValue:
        return append (v.asBool());

    case Json::objectValue:
    {
        auto object = appendObject ();
        copyFrom (object, v);
        return;
    }

    case Json::arrayValue:
    {
        auto array = appendArray ();
        for (auto& item: v)
            array.append (item);
        return;
    }
    }
    assert (false);  // Can't get here.
}
コード例 #4
0
ファイル: queryOperation.c プロジェクト: zaneb/sblim-sfcb
static PredicateConjunction* andGetPredicateConjunction(QLOperation* op) 
{
   PredicateConjunction *lc=op->lhon->ft->getPredicateConjunction(op->lhon);
   if (!op->rhon) return lc;
   PredicateConjunction *rc=op->rhon->ft->getPredicateConjunction(op->rhon);
   appendArray(lc,rc);
   return lc;
}
コード例 #5
0
ファイル: queryOperation.c プロジェクト: zaneb/sblim-sfcb
PredicateDisjunction *orGetPredicatesDisjunction(QLOperation *op) 
{
   PredicateDisjunction *lc=op->lhon->ft->getPredicateDisjunction(op->lhon);
   if (!op->rhon) return lc;
   PredicateDisjunction *rc=op->rhon->ft->getPredicateDisjunction(op->rhon);
   appendArray(lc,rc);
   
   return lc;
}
コード例 #6
0
ファイル: bsonobjbuilder.cpp プロジェクト: ANTco/mongo
 void BSONObjBuilder::appendMinForType( const StringData& fieldName , int t ) {
     switch ( t ) {
             
     // Shared canonical types
     case NumberInt:
     case NumberDouble:
     case NumberLong:
         append( fieldName , - std::numeric_limits<double>::max() ); return;
     case Symbol:
     case String:
         append( fieldName , "" ); return;
     case Date: 
         // min varies with V0 and V1 indexes, so we go one type lower.
         appendBool(fieldName, true);
         //appendDate( fieldName , numeric_limits<long long>::min() ); 
         return;
     case Timestamp: // TODO integrate with Date SERVER-3304
         appendTimestamp( fieldName , 0 ); return;
     case Undefined: // shared with EOO
         appendUndefined( fieldName ); return;
             
     // Separate canonical types
     case MinKey:
         appendMinKey( fieldName ); return;
     case MaxKey:
         appendMaxKey( fieldName ); return;
     case jstOID: {
         OID o;
         appendOID( fieldName , &o);
         return;
     }
     case Bool:
         appendBool( fieldName , false); return;
     case jstNULL:
         appendNull( fieldName ); return;
     case Object:
         append( fieldName , BSONObj() ); return;
     case Array:
         appendArray( fieldName , BSONObj() ); return;
     case BinData:
         appendBinData( fieldName , 0 , BinDataGeneral , (const char *) 0 ); return;
     case RegEx:
         appendRegex( fieldName , "" ); return;
     case DBRef: {
         OID o;
         appendDBRef( fieldName , "" , o );
         return;
     }
     case Code:
         appendCode( fieldName , "" ); return;
     case CodeWScope:
         appendCodeWScope( fieldName , "" , BSONObj() ); return;
     };
     log() << "type not supported for appendMinElementForType: " << t;
     uassert( 10061 ,  "type not supported for appendMinElementForType" , false );
 }
コード例 #7
0
CppEchoPersonInfoResponse* EsdlExampleService::CppEchoPersonInfo(EsdlContext* context, CppEchoPersonInfoRequest* request)
{
    Owned<CppEchoPersonInfoResponse> resp = new CppEchoPersonInfoResponse();
    //Fill in logic
    resp->count.setown(new Integer(0));
    if(request->Name)
    {
        resp->count.setown(new Integer(1));
        resp->Name.set(request->Name.get());
    }
    appendArray(resp->Addresses, request->Addresses);
    return resp.getClear();
}
コード例 #8
0
ファイル: projection_exec.cpp プロジェクト: enlyn/mongo
    void ProjectionExec::appendArray(BSONObjBuilder* bob, const BSONObj& array, bool nested) const {
        int skip  = nested ?  0 : _skip;
        int limit = nested ? -1 : _limit;

        if (skip < 0) {
            skip = max(0, skip + array.nFields());
        }

        int index = 0;
        BSONObjIterator it(array);
        while (it.more()) {
            BSONElement elt = it.next();

            if (skip) {
                skip--;
                continue;
            }

            if (limit != -1 && (limit-- == 0)) {
                break;
            }

            switch(elt.type()) {
            case Array: {
                BSONObjBuilder subBob;
                appendArray(&subBob, elt.embeddedObject(), true);
                bob->appendArray(bob->numStr(index++), subBob.obj());
                break;
            }
            case Object: {
                BSONObjBuilder subBob;
                BSONObjIterator jt(elt.embeddedObject());
                while (jt.more()) {
                    append(&subBob, jt.next());
                }
                bob->append(bob->numStr(index++), subBob.obj());
                break;
            }
            default:
                if (_include) {
                    bob->appendAs(elt, bob->numStr(index++));
                }
            }
        }
    }
コード例 #9
0
ファイル: projection.cpp プロジェクト: 7segments/mongo
    //b will be the value part of an array-typed BSONElement
    void Projection::appendArray( BSONObjBuilder& b , const BSONObj& a , bool nested) const {
        int skip  = nested ?  0 : _skip;
        int limit = nested ? -1 : _limit;

        if (skip < 0) {
            skip = max(0, skip + a.nFields());
        }

        int i=0;
        BSONObjIterator it(a);
        while (it.more()) {
            BSONElement e = it.next();

            if (skip) {
                skip--;
                continue;
            }

            if (limit != -1 && (limit-- == 0)) {
                break;
            }

            switch(e.type()) {
            case Array: {
                BSONObjBuilder subb;
                appendArray(subb , e.embeddedObject(), true);
                b.appendArray(b.numStr(i++), subb.obj());
                break;
            }
            case Object: {
                BSONObjBuilder subb;
                BSONObjIterator jt(e.embeddedObject());
                while (jt.more()) {
                    append(subb , jt.next());
                }
                b.append(b.numStr(i++), subb.obj());
                break;
            }
            default:
                if (_include)
                    b.appendAs(e, b.numStr(i++));
            }
        }
    }
コード例 #10
0
ファイル: jsobj.cpp プロジェクト: fes/mongo
    void BSONObjBuilder::appendMinForType( const string& field , int t ){
        switch ( t ){
        case MinKey: appendMinKey( field.c_str() ); return;
        case MaxKey: appendMinKey( field.c_str() ); return;
        case NumberInt:
        case NumberDouble:
        case NumberLong:
            append( field.c_str() , - numeric_limits<double>::max() ); return;
        case jstOID: 
            { 
                OID o;
                memset(&o, 0, sizeof(o));
                appendOID( field.c_str() , &o);
                return;
            }
        case Bool: appendBool( field.c_str() , false); return;
        case Date: appendDate( field.c_str() , 0); return;
        case jstNULL: appendNull( field.c_str() ); return;
        case String: append( field.c_str() , "" ); return;
        case Object: append( field.c_str() , BSONObj() ); return;
        case Array: 
            appendArray( field.c_str() , BSONObj() ); return;
        case BinData:  
            appendBinData( field.c_str() , 0 , Function , 0 ); return;
        case Undefined:
            appendUndefined( field.c_str() ); return;
        case RegEx: appendRegex( field.c_str() , "" ); return;
        case DBRef:
            {
                OID o;
                memset(&o, 0, sizeof(o));
                appendDBRef( field.c_str() , "" , o );
                return;
            }
        case Code: appendCode( field.c_str() , "" ); return;
        case Symbol: appendSymbol( field.c_str() , "" ); return;
        case CodeWScope: appendCodeWScope( field.c_str() , "" , BSONObj() ); return;
        case Timestamp: appendTimestamp( field.c_str() , 0); return;

        };
        log() << "type not support for appendMinElementForType: " << t << endl;
        uassert( "type not supported for appendMinElementForType" , false );
    }
コード例 #11
0
ファイル: nl-liststr.c プロジェクト: baisoo/kitphone
CELL * p_append(CELL * params)
{
CELL * list = NULL;
CELL * firstCell = NULL;
CELL * copy = NULL;
CELL * cell;

while(params != nilCell)
    {
    params = getEvalDefault(params, &cell);
    if(!isList(cell->type))
        {
        if(copy == NULL)
			{
			if(cell->type == CELL_STRING)
            	return(appendString(cell, params, NULL, 0, FALSE, TRUE));
			else if(cell->type == CELL_ARRAY)
            	return(appendArray(cell, params));
			return(errorProcExt(ERR_ARRAY_LIST_OR_STRING_EXPECTED, cell));
			}
		
        return(errorProcExt(ERR_LIST_EXPECTED, cell));
        }

	if(list == NULL)
        list = getCell(cell->type);

    copy = copyList((CELL *)cell->contents);

    if(copy == nilCell) continue;

    if(firstCell == NULL) list->contents = (UINT)copy;
    else firstCell->next = copy;

    firstCell = lastCellCopied;
    }

if(list == NULL)
	return(getCell(CELL_EXPRESSION));

return(list);
}
コード例 #12
0
void ViewFieldECLTransformer::transform(unsigned & lenTarget, char * & target, unsigned lenSource, const char * source, const HqlExprArray & extraArgs)
{
    Owned<ITypeInfo> sourceType = makeUtf8Type(lenSource, 0);
    IValue * sourceValue = createUtf8Value(source, LINK(sourceType));
    OwnedHqlExpr sourceExpr = createConstant(sourceValue);
    HqlExprArray actuals;
    actuals.append(*LINK(sourceExpr));
    appendArray(actuals, extraArgs);

    Owned<IErrorReceiver> errorReporter = createThrowingErrorReceiver();
    OwnedHqlExpr call = createBoundFunction(errorReporter, function, actuals, NULL, true);
    OwnedHqlExpr castValue = ensureExprType(call, utf8Type);
    OwnedHqlExpr folded = quickFoldExpression(castValue, NULL, 0);
    IValue * foldedValue = folded->queryValue();
    assertex(foldedValue);
    unsigned len = foldedValue->queryType()->getStringLen();
    const char * data = static_cast<const char *>(foldedValue->queryValue());
    unsigned size = rtlUtf8Size(len, data);
    lenTarget = len;
    target = (char *)rtlMalloc(size);
    memcpy(target, data, size);
}
コード例 #13
0
ViewAddTransformer::ViewAddTransformer(const HqlExprArray & _args) : ViewFieldTransformer(addAtom)
{
    appendArray(args, _args);
}
コード例 #14
0
ファイル: nms.cpp プロジェクト: ToughLife/libpabod
void nms (int** pick, int *pickDim,  
          CvMat *dets, double overlap)
{
  if (dets == NULL)
  {
    *pick = NULL;
    *pickDim = 0;
  }

  else
  {
    *pick = NULL;
    *pickDim = 0;

    int *rows = new int [dets->rows];
    for (int i = 0; i < dets->rows; i++)
      rows[i] = i;  

    int col;
    col = 0;
    CvMat *x1 = subMat (dets, rows, dets->rows, &col, 1);
    double *x1Ptr = new double [x1->rows * x1->cols];
    getMatData <double> (x1, x1Ptr);

    col = 1;
    CvMat *y1 = subMat (dets, rows, dets->rows, &col, 1);
    double *y1Ptr = new double [y1->rows * y1->cols];
    getMatData <double> (y1, y1Ptr);

    col = 2;
    CvMat *x2 = subMat (dets, rows, dets->rows, &col, 1);
    double *x2Ptr = new double [x2->rows * x2->cols];
    getMatData <double> (x2, x2Ptr);

    col = 3;
    CvMat *y2 = subMat (dets, rows, dets->rows, &col, 1);
    double *y2Ptr = new double [y2->rows * y2->cols];
    getMatData <double> (y2, y2Ptr);

    col = 5;
    CvMat *s = subMat (dets, rows, dets->rows, &col, 1);
    double *sPtr = new double [s->rows * s->cols];
    getMatData <double> (s, sPtr);

    int areaDims[2] = {dets->rows, 1};

    CvMat *area;
    createMatrix (2, areaDims, CV_64FC1, &area);
    CvMat *p1, *p2;
    p1 = cvCloneMat (x1);
    p2 = cvCloneMat (y1);
    cvSub (x2, x1, p1);
    cvAddS (p1, cvScalar(1), p1);
    cvSub (y2, y1, p2);
    cvAddS (p2, cvScalar(1), p2);
    cvMul (p1, p2, area);

    double *areaPtr = new double [area->rows * area->cols];
    getMatData <double> (area, areaPtr);

    cvReleaseMat (&x1);
    cvReleaseMat (&y1);
    cvReleaseMat (&x2);
    cvReleaseMat (&y2);
    cvReleaseMat (&x1);
    cvReleaseMat (&s);
    cvReleaseMat (&area);
    cvReleaseMat (&p1);
    cvReleaseMat (&p2);
    delete[] rows;

    int idxDim = dets->rows;
    int *idx = new int [idxDim];

    shellSort (sPtr, dets->rows, ASCEND, &idx);

    int last;
    int i;
    int *suppress = NULL;
    int suppressDim = 0;

    int j;

    double xx1;
    double yy1;
    double xx2;
    double yy2;  
    double w;
    double h;

    double o;

    while (idxDim > 0)
    {
      last = idxDim-1;
      i = idx[last];
      appendArray (pick, (*pickDim), &i, 1);
      (*pickDim)++;

      suppress = NULL;
      suppressDim = 0;
      appendArray (&suppress, suppressDim, &last, 1);
      suppressDim++;

      for (int pos = 0; pos < last; pos++)
      {  
        j = idx[pos];

        xx1 = max (x1Ptr[i], x1Ptr[j]);
        yy1 = max (y1Ptr[i], y1Ptr[j]);
        xx2 = min (x2Ptr[i], x2Ptr[j]);
        yy2 = min (y2Ptr[i], y2Ptr[j]);  
        w = xx2 - xx1 + 1;
        h = yy2 - yy1 + 1;

        if (w > 0 && h > 0)
        {
          // Compute overlap
          o = (w * h) / areaPtr[j];

          if (o > overlap)
          {
            appendArray (&suppress, suppressDim, &pos, 1);
            suppressDim++;
          }
        }
      }

      removeIndexes (&idx, idxDim, suppress, suppressDim);
      idxDim -= suppressDim;

      delete[] suppress;
    }

    delete[] x1Ptr;
    delete[] y1Ptr;
    delete[] x2Ptr;
    delete[] y2Ptr;
    delete[] sPtr;
    delete[] areaPtr;
    delete[] idx;
  }
}
コード例 #15
0
//!
//! Appends \a block to the end of the write buffer.
void ByteStream::appendWrite(const QByteArray &block)
{
	appendArray(&d->writeBuf, block);
}
コード例 #16
0
//!
//! Appends \a block to the end of the read buffer.
void ByteStream::appendRead(const QByteArray &block)
{
	appendArray(&d->readBuf, block);
}