Ejemplo n.º 1
0
Archivo: Osc.cpp Proyecto: EQ4/MRP
int OscReceiver::handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *data)
{
	bool matched = false;
	
	string pathString(path);	
	
	if(useThru_)
	{
		// Rebroadcast any matching messages
		
		if(!pathString.compare(0, thruPrefix_.length(), thruPrefix_))
			lo_send_message(thruAddress_, path, msg);
	}
	
	// Check if the incoming message matches the global prefix for this program.  If not, discard it.
	if(pathString.compare(0, globalPrefix_.length(), globalPrefix_))
	{
		cout << "OSC message '" << path << "' received\n";
		return 1;
	}
	
	// Lock the mutex so the list of listeners doesn't change midway through
	pthread_mutex_lock(&oscListenerMutex_);
	
	// Now remove the global prefix and compare the rest of the message to the registered handlers.
	multimap<string, OscHandler*>::iterator it;
	pair<multimap<string, OscHandler*>::iterator,multimap<string, OscHandler*>::iterator> ret;
	string truncatedPath = pathString.substr(globalPrefix_.length(), 
											 pathString.length() - globalPrefix_.length());
	ret = noteListeners_.equal_range(truncatedPath);
	
	it = ret.first;
	while(it != ret.second)
	{
		OscHandler *object = (*it++).second;
		
#ifdef DEBUG_MESSAGES
		cout << "Matched OSC path '" << path << "' to handler " << object << endl;
#endif
		object->oscHandlerMethod(truncatedPath.c_str(), types, argc, argv, data);
		matched = true;
	}
	
	pthread_mutex_unlock(&oscListenerMutex_);
	
	if(matched)		// This message has been handled
		return 0;
	
	printf("Unhandled OSC path: <%s>\n", path);
	
#ifdef DEBUG_MESSAGES
    for (int i=0; i<argc; i++) {
		printf("arg %d '%c' ", i, types[i]);
		lo_arg_pp((lo_type)types[i], argv[i]);
		printf("\n");
    }
#endif
	
    return 1;
}
Ejemplo n.º 2
0
// It's assumed that lightmaps aren't passed into this callback...
static void AssignIndex( wApiImageInfo_t* info, uint16_t assignIndex )
{
	std::string pathString( info->name );

	if ( gImageTracker->isKeyMapped )
	{
		size_t keyMap =
			( size_t ) gImageTracker->textureInfo[ pathString ];

		gImageTracker->destAtlas->map_key_to_image(
			keyMap,
			assignIndex
		);

	//	if ( assignIndex == gla::atlas_t::no_image_index )
	//	{
	//		gImageTracker->map->MarkBadTexture( keyMap );
	//	}
	}
	else
	{
		shaderStage_t* stage =
			( shaderStage_t* ) gImageTracker->textureInfo[ pathString ];

		// This index will persist in the texture array it's going into
		stage->textureIndex = assignIndex;
	}

	gImageTracker->iterator++;
}
Ejemplo n.º 3
0
status_t
ExpanderThread::ThreadStartup()
{
	status_t status = B_OK;
	entry_ref srcRef;
	entry_ref destRef;
	BString cmd;

	if ((status = GetDataStore()->FindRef("srcRef", &srcRef)) != B_OK)
		return status;

	if ((status = GetDataStore()->FindRef("destRef", &destRef)) == B_OK) {
		BPath path(&destRef);
		chdir(path.Path());
	}

	if ((status = GetDataStore()->FindString("cmd", &cmd)) != B_OK)
		return status;

	BPath path(&srcRef);
	BString pathString(path.Path());
	pathString.CharacterEscape("\\\"$`", '\\');
	pathString.Prepend("\"");
	pathString.Append("\"");
	cmd.ReplaceAll("%s", pathString.String());

	int32 argc = 3;
	const char** argv = new const char * [argc + 1];

	argv[0] = strdup("/bin/sh");
	argv[1] = strdup("-c");
	argv[2] = strdup(cmd.String());
	argv[argc] = NULL;

	fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);

	delete [] argv;

	if (fThreadId < 0)
		return fThreadId;

	// lower the command priority since it is a background task.
	set_thread_priority(fThreadId, B_LOW_PRIORITY);

	resume_thread(fThreadId);

	int flags = fcntl(fStdOut, F_GETFL, 0);
	flags |= O_NONBLOCK;
	fcntl(fStdOut, F_SETFL, flags);
	flags = fcntl(fStdErr, F_GETFL, 0);
	flags |= O_NONBLOCK;
	fcntl(fStdErr, F_SETFL, flags);

	fExpanderOutput = fdopen(fStdOut, "r");
	fExpanderError = fdopen(fStdErr, "r");

	return B_OK;
}
Ejemplo n.º 4
0
BString
IncludeSettingsView::GetListContent(BListView* list)
{
	BString pathString("");
	BListItem* item;
	int32 nItems = list->CountItems();
	for (int32 i = 0; i < nItems; i++) {
		item = list->ItemAt(i);
		pathString += ((BStringItem*)item)->Text();
		pathString += " ";
	}
	return pathString;
}
Ejemplo n.º 5
0
void CleanupTab::updateGui(CleanupParameters *params, CleanupParameters *oldParams)
{
	m_autoCenter->setChecked(params->m_autocenterType == CleanupTypes::AUTOCENTER_FDG);
	m_pegHolesOm->setCurrentIndex(params->m_pegSide - 1);

	QString fieldName = QString::fromStdString(params->getFdgName());
	int index = (fieldName.isEmpty()) ? 0 : m_fieldGuideOm->findText(fieldName);
	assert(index != -1);
	m_fieldGuideOm->setCurrentIndex(index);

	m_rotateOm->setCurrentIndex(params->m_rotate / 90);
	m_flipX->setChecked(params->m_flipx);
	m_flipY->setChecked(params->m_flipy);

	m_path = params->m_path;
	m_pathField->setPath(pathString(m_path, params->m_lineProcessingMode == lpNone));
}
Ejemplo n.º 6
0
    intrusive_ptr<DocumentSource> DocumentSourceUnwind::createFromBson(
        BSONElement *pBsonElement,
        const intrusive_ptr<ExpressionContext> &pExpCtx) {
        /*
          The value of $unwind should just be a field path.
         */
        uassert(15981, str::stream() << "the " << unwindName <<
                " field path must be specified as a string",
                pBsonElement->type() == String);

        string prefixedPathString(pBsonElement->str());
        string pathString(Expression::removeFieldPrefix(prefixedPathString));
        intrusive_ptr<DocumentSourceUnwind> pUnwind(new DocumentSourceUnwind(pExpCtx));
        pUnwind->unwindPath(FieldPath(pathString));

        return pUnwind;
    }
Ejemplo n.º 7
0
void addModuleSearchPath(const std::string& path)
{
    std::string pathString("path");
    auto syspath = PySys_GetObject(&pathString[0]); // Borrowed reference

    PythonObject pypath(PythonObject::owning {},
        PyString_FromString(path.c_str()));

    if (!pypath) {
        throw WrappyError("Wrappy: Can't allocate memory for string.");
    }

    auto pos = PyList_Insert(syspath, 0, pypath.get());
    if (pos < 0) {
        throw WrappyError("Wrappy: Couldn't add " + path + " to sys.path");
    }
}
Ejemplo n.º 8
0
void
MediaConverterWindow::TruncateOutputFolderPath()
{
	BEntry entry;
	fOutputDir.GetEntry(&entry);
	BPath path;
	entry.GetPath(&path);
	BString pathString(path.Path());
	float maxWidth = fVideoMenu->MenuBar()->Frame().Width();

	fOutputFolder->TruncateString(&pathString, B_TRUNCATE_MIDDLE, maxWidth);
	fOutputFolder->SetText(pathString.String());
	if (fOutputFolder->StringWidth(path.Path()) > maxWidth)
		fOutputFolder->SetToolTip(path.Path());
	else
		fOutputFolder->SetToolTip((const char*)NULL);
}
Ejemplo n.º 9
0
// (call 'any ..) -> flg
any doCall(any ex) {
   pid_t pid;
   any x, y;
   int res, i, ac = length(x = cdr(ex));
   char *av[ac+1];

   if (ac == 0)
      return Nil;
   av[0] = alloc(NULL, pathSize(y = evSym(x))),  pathString(y, av[0]);
   for (i = 1; isCell(x = cdr(x)); ++i)
      av[i] = alloc(NULL, bufSize(y = evSym(x))),  bufString(y, av[i]);
   av[ac] = NULL;
   flushAll();
   if ((pid = fork()) == 0) {
      setpgid(0,0);
      execvp(av[0], av);
      execError(av[0]);
   }
   i = 0;  do
      free(av[i]);
   while (++i < ac);
   if (pid < 0)
      err(ex, NULL, "fork");
   setpgid(pid,0);
   if (Termio)
      tcsetpgrp(0,pid);
   for (;;) {
      while (waitpid(pid, &res, WUNTRACED) < 0) {
         if (errno != EINTR)
            err(ex, NULL, "wait pid");
         if (*Signal)
            sighandler(ex);
      }
      if (Termio)
         tcsetpgrp(0,getpgrp());
      if (!WIFSTOPPED(res))
         return res == 0? T : Nil;
      load(NULL, '+', Nil);
      if (Termio)
         tcsetpgrp(0,pid);
      kill(pid, SIGCONT);
   }
}
Ejemplo n.º 10
0
void
IncludeSettingsView::PopulatePathList(BListView* list, const char* paths)
{
	//prerequisites: "paths" string is a list of dirs separated by white spaces.
	//the last character is a white space.
	BString pathString(paths);
	BString itemName;
	int32 slen = pathString.CountChars();
	int32 index = 0, lastBlank = -1;
	//scan the string for white spaces
	while (index < slen) {	
		//word boundaries are white spaces
		if (pathString[index] == ' ') {
			//add the string from 'lastBlank' to 'index' - 1 to the list view
			pathString.CopyInto(itemName, lastBlank + 1, index - lastBlank - 1);
			list->AddItem(new BStringItem(itemName.String()));
			lastBlank = index;
		}
		index++;
	}
}
Ejemplo n.º 11
0
void ChromeClient::runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser> chooser)
{
    //cexer 实现文件选择
    wchar_t* pathList = new wchar_t[10 * MAX_PATH];
    memset(pathList, 0, 10 * MAX_PATH * sizeof(wchar_t));

    OPENFILENAMEW ofn = { 0 };
    ofn.Flags = OFN_DONTADDTORECENT|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_NONETWORKBUTTON|OFN_PATHMUSTEXIST;
    if (chooser->settings().allowsMultipleFiles)
        ofn.Flags |= OFN_ALLOWMULTISELECT;

    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = NULL;
    ofn.lpstrFilter = L"*.*\0*.*\0\0";
    ofn.lpstrFile = pathList;
    ofn.nMaxFile = 10 * MAX_PATH;
    ofn.lpstrInitialDir = NULL;
    ofn.lpstrTitle = NULL;
    if (0 != GetOpenFileNameW(&ofn))
    {
        Vector<String> chosenFiles;

        wchar_t* path = pathList;
        while (*path)
        {
            size_t pathLen = wcslen(path);

            String pathString((const UChar*)path, pathLen);
            chosenFiles.append(pathString);

            path += pathLen + 1;
        }

        if (!chosenFiles.isEmpty())
            chooser->chooseFiles(chosenFiles);
    }

    delete [] pathList;
}
Ejemplo n.º 12
0
    int OVCINList::load(const char *loadpath, const char *extension) {
		int loaded=0;
		BOOL fFinished;
		HANDLE hList;
		WIN32_FIND_DATA FileData;
		string pathString(loadpath);
		pathString += "\\*";
		pathString += extension;
		const char* findpath = pathString.c_str();
		hList = FindFirstFile(findpath, &FileData);
		if(hList == INVALID_HANDLE_VALUE)
		{
			murmur("No files found in %s\n", pathString.c_str());
		}
		else
		{
			fFinished = FALSE;
			while (!fFinished)
			{
				if(strstr(FileData.cFileName, extension))
				{
					if (preparse(loadpath, FileData.cFileName)) loaded++;
				}
				if (!FindNextFile(hList, &FileData))
				{
					if (GetLastError() == ERROR_NO_MORE_FILES)
					{
						fFinished = TRUE;
					}
				}
			}
		}
		FindClose(hList);
		return loaded;
        // murmur("OVCINList::load called, index=%d", index);
    }
Ejemplo n.º 13
0
int OscController::handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *data)
{
	bool matched = false;
	
#ifdef DEBUG_MESSAGES_EXTRA
	cout << "Received OSC message " << path << " [" << types << "]\n";
#endif
	
	if(useOscMidi_)	// OSC MIDI emulation.  Also the most time-sensitive & frequent message so do this first.
	{
		if(!strcmp(path, "/mrp/midi") && argc >= 1)
		{
			if(types[0] == 'm')
				return handleMidi(argv[0]->m[1], argv[0]->m[2], argv[0]->m[3]);
			if(argc >= 3)
				if(types[0] == 'i' && types[1] == 'i' && types[2] == 'i')
					return handleMidi((unsigned char)argv[0]->i, (unsigned char)argv[1]->i, (unsigned char)argv[2]->i);
		}
		if(!strcmp(path, "/mrp/quality/brightness") && argc >= 3)
		{
			if(types[0] == 'i' && types[1] == 'i' && types[2] == 'f')
				return handleRtBrightness(argv);
		}
		if(!strcmp(path, "/mrp/quality/intensity") && argc >= 3)
		{
			if(types[0] == 'i' && types[1] == 'i' && types[2] == 'f')
				return handleRtIntensity(argv);
		}
		if(!strcmp(path, "/mrp/quality/pitch") && argc >= 3)
		{
			if(types[0] == 'i' && types[1] == 'i' && types[2] == 'f')
				return handleRtPitch(argv);
		}
        if(!strcmp(path, "/mrp/quality/pitch/vibrato") && argc >= 3)
		{
			if(types[0] == 'i' && types[1] == 'i' && types[2] == 'f')
				return handleRtPitchVibrato(argv);
		}
		if(!strcmp(path, "/mrp/quality/harmonic") && argc >= 3)
		{
			if(types[0] == 'i' && types[1] == 'i' && types[2] == 'f')
				return handleRtHarmonic(argv);
		}
        if(!strcmp(path, "/mrp/quality/harmonics/raw") && argc >= 3)
		{
			if(types[0] == 'i' && types[1] == 'i' && types[2] == 'f')
				return handleRtHarmonicsRaw(argc, types, argv);
		}
        if(!strcmp(path, "/mrp/volume") && argc >= 1)
		{
			if(types[0] == 'f')
            {
                cout << "setting volume to " << argv[0]->f << endl;
                midiController_->render_->setGlobalAmplitude(argv[0]->f);
				return 0;
            }
		}
        if(!strcmp(path, "/mrp/global/harmonics") && argc == 2)
		{
			if(types[0] == 'i' || types[1] == 'f')
				midiController_->oscHandleGlobalParameters(path, types, 2, argv, data);
		}
        if(!strcmp(path, "/mrp/allnotesoff"))
		{
            allNotesOff();
		}
	}

	string pathString(path);	
	
	if(useThru_)
	{
		// Rebroadcast any matching messages
		
		if(!pathString.compare(0, thruPrefix_.length(), thruPrefix_))
			lo_send_message(thruAddress_, path, msg);
	}
	
	// Check if the incoming message matches the global prefix for this program.  If not, discard it.
	if(pathString.compare(0, globalPrefix_.length(), globalPrefix_))
	{
		cout << "OSC message '" << path << "' received\n";
		return 1;
	}
	
	// Lock the mutex so the list of listeners doesn't change midway through
	pthread_mutex_lock(&oscListenerMutex_);
	
	// Now remove the global prefix and compare the rest of the message to the registered handlers.
	multimap<string, OscHandler*>::iterator it;
	pair<multimap<string, OscHandler*>::iterator,multimap<string, OscHandler*>::iterator> ret;
	string truncatedPath = pathString.substr(globalPrefix_.length(), 
											 pathString.length() - globalPrefix_.length());
	ret = noteListeners_.equal_range(truncatedPath);
	
	it = ret.first;
	while(it != ret.second)
	{
		OscHandler *object = (*it++).second;
		
#ifdef DEBUG_MESSAGES_EXTRA
		cout << "Matched OSC path '" << path << "' to handler " << object << endl;
#endif
		object->oscHandlerMethod(truncatedPath.c_str(), types, argc, argv, data);
		matched = true;
	}
	
	pthread_mutex_unlock(&oscListenerMutex_);
	
	if(matched)		// This message has been handled
		return 0;
	
	printf("Unhandled OSC path: <%s>\n", path);
/*#ifdef DEBUG_MESSAGES
	for (i=0; i<argc; i++) {
		printf("arg %d '%c' ", i, types[i]);
		lo_arg_pp((lo_type)types[i], argv[i]);
		printf("\n");
	}
#endif*/

    return 1;
}
Ejemplo n.º 14
0
intrusive_ptr<DocumentSource> DocumentSourceGroup::createFromBson(
    BSONElement *pBsonElement,
    const intrusive_ptr<ExpressionContext> &pCtx) {
    assert(pBsonElement->type() == Object); // CW TODO must be an object

    intrusive_ptr<DocumentSourceGroup> pGroup(
        DocumentSourceGroup::create(pCtx));
    bool idSet = false;

    BSONObj groupObj(pBsonElement->Obj());
    BSONObjIterator groupIterator(groupObj);
    while(groupIterator.more()) {
        BSONElement groupField(groupIterator.next());
        const char *pFieldName = groupField.fieldName();

        if (strcmp(pFieldName, Document::idName.c_str()) == 0) {
            assert(!idSet); // CW TODO _id specified multiple times

            BSONType groupType = groupField.type();

            if (groupType == Object) {
                /*
                  Use the projection-like set of field paths to create the
                  group-by key.
                */
                Expression::ObjectCtx oCtx(
                    Expression::ObjectCtx::DOCUMENT_OK);
                intrusive_ptr<Expression> pId(
                    Expression::parseObject(&groupField, &oCtx));

                pGroup->setIdExpression(pId);
                idSet = true;
            }
            else if (groupType == String) {
                string groupString(groupField.String());
                const char *pGroupString = groupString.c_str();
                if ((groupString.length() == 0) ||
                        (pGroupString[0] != '$'))
                    goto StringConstantId;

                string pathString(
                    Expression::removeFieldPrefix(groupString));
                intrusive_ptr<ExpressionFieldPath> pFieldPath(
                    ExpressionFieldPath::create(pathString));
                pGroup->setIdExpression(pFieldPath);
                idSet = true;
            }
            else {
                /* pick out the constant types that are allowed */
                switch(groupType) {
                case NumberDouble:
                case String:
                case Object:
                case Array:
                case jstOID:
                case Bool:
                case Date:
                case NumberInt:
                case Timestamp:
                case NumberLong:
                case jstNULL:
StringConstantId: // from string case above
                    {
                        intrusive_ptr<const Value> pValue(
                            Value::createFromBsonElement(&groupField));
                        intrusive_ptr<ExpressionConstant> pConstant(
                            ExpressionConstant::create(pValue));
                        pGroup->setIdExpression(pConstant);
                        idSet = true;
                        break;
                    }

                default:
                    assert(false);
                    // CW TODO disallowed constant group key
                }
            }
        }
        else {
            /*
              Treat as a projection field with the additional ability to
              add aggregation operators.
            */
            assert(*pFieldName != '$');
            // CW TODO error: field name can't be an operator
            assert(groupField.type() == Object);
            // CW TODO error: must be an operator expression

            BSONObj subField(groupField.Obj());
            BSONObjIterator subIterator(subField);
            size_t subCount = 0;
            for(; subIterator.more(); ++subCount) {
                BSONElement subElement(subIterator.next());

                /* look for the specified operator */
                GroupOpDesc key;
                key.pName = subElement.fieldName();
                const GroupOpDesc *pOp =
                    (const GroupOpDesc *)bsearch(
                        &key, GroupOpTable, NGroupOp, sizeof(GroupOpDesc),
                        GroupOpDescCmp);

                assert(pOp); // CW TODO error: operator not found

                intrusive_ptr<Expression> pGroupExpr;

                BSONType elementType = subElement.type();
                if (elementType == Object) {
                    Expression::ObjectCtx oCtx(
                        Expression::ObjectCtx::DOCUMENT_OK);
                    pGroupExpr = Expression::parseObject(
                                     &subElement, &oCtx);
                }
                else if (elementType == Array) {
                    assert(false); // CW TODO group operators are unary
                }
                else { /* assume its an atomic single operand */
                    pGroupExpr = Expression::parseOperand(&subElement);
                }

                pGroup->addAccumulator(
                    pFieldName, pOp->pFactory, pGroupExpr);
            }

            assert(subCount == 1);
            // CW TODO error: only one operator allowed
        }
    }

    assert(idSet); // CW TODO error: missing _id specification

    return pGroup;
}
Ejemplo n.º 15
0
bool CoreEngine::setSymbolPaths(const QStringList &s, QString *errorMessage)
{
    const HRESULT hr = m_cif.debugSymbols->SetSymbolPathWide(reinterpret_cast<PCWSTR>(pathString(s).utf16()));
    if (FAILED(hr)) {
        if (errorMessage)
            *errorMessage = msgComFailed("SetSymbolPathWide", hr);
        return false;
    }
    return true;
}
Ejemplo n.º 16
0
    intrusive_ptr<DocumentSource> DocumentSourceGroup::createFromBson(
	BSONElement *pBsonElement,
	const intrusive_ptr<ExpressionContext> &pCtx) {
	uassert(15947, "a group's fields must be specified in an object",
		pBsonElement->type() == Object);

        intrusive_ptr<DocumentSourceGroup> pGroup(
	    DocumentSourceGroup::create(pCtx));
        bool idSet = false;

        BSONObj groupObj(pBsonElement->Obj());
        BSONObjIterator groupIterator(groupObj);
        while(groupIterator.more()) {
            BSONElement groupField(groupIterator.next());
            const char *pFieldName = groupField.fieldName();

            if (strcmp(pFieldName, Document::idName.c_str()) == 0) {
		uassert(15948, "a group's _id may only be specified once",
			!idSet);

		BSONType groupType = groupField.type();

		if (groupType == Object) {
		    /*
		      Use the projection-like set of field paths to create the
		      group-by key.
		    */
		    Expression::ObjectCtx oCtx(
			Expression::ObjectCtx::DOCUMENT_OK);
		    intrusive_ptr<Expression> pId(
			Expression::parseObject(&groupField, &oCtx));

		    pGroup->setIdExpression(pId);
		    idSet = true;
		}
		else if (groupType == String) {
		    string groupString(groupField.String());
		    const char *pGroupString = groupString.c_str();
		    if ((groupString.length() == 0) ||
			(pGroupString[0] != '$'))
			goto StringConstantId;

		    string pathString(
			Expression::removeFieldPrefix(groupString));
		    intrusive_ptr<ExpressionFieldPath> pFieldPath(
			ExpressionFieldPath::create(pathString));
		    pGroup->setIdExpression(pFieldPath);
		    idSet = true;
		}
		else {
		    /* pick out the constant types that are allowed */
		    switch(groupType) {
		    case NumberDouble:
		    case String:
		    case Object:
		    case Array:
		    case jstOID:
		    case Bool:
		    case Date:
		    case NumberInt:
		    case Timestamp:
		    case NumberLong:
		    case jstNULL:
		    StringConstantId: // from string case above
		    {
			intrusive_ptr<const Value> pValue(
			    Value::createFromBsonElement(&groupField));
			intrusive_ptr<ExpressionConstant> pConstant(
			    ExpressionConstant::create(pValue));
			pGroup->setIdExpression(pConstant);
			idSet = true;
			break;
		    }

		    default:
			uassert(15949, str::stream() <<
				"a group's _id may not include fields of BSON type " << groupType,
				false);
		    }
		}
            }
            else {
                /*
                  Treat as a projection field with the additional ability to
                  add aggregation operators.
                */
		uassert(15950, str::stream() <<
			"the group aggregate field name " <<
			*pFieldName << " cannot be an operator name",
			*pFieldName != '$');

		uassert(15951, str::stream() << 
			"the group aggregate field " << *pFieldName <<
			"must be defined as an expression inside an object",
			groupField.type() == Object);

                BSONObj subField(groupField.Obj());
                BSONObjIterator subIterator(subField);
                size_t subCount = 0;
                for(; subIterator.more(); ++subCount) {
                    BSONElement subElement(subIterator.next());

                    /* look for the specified operator */
                    GroupOpDesc key;
                    key.pName = subElement.fieldName();
                    const GroupOpDesc *pOp =
			(const GroupOpDesc *)bsearch(
                              &key, GroupOpTable, NGroupOp, sizeof(GroupOpDesc),
                                      GroupOpDescCmp);

		    uassert(15952, str::stream() <<
			    "unknown group operator \"" <<
			    key.pName << "\"",
			    pOp);

                    intrusive_ptr<Expression> pGroupExpr;

                    BSONType elementType = subElement.type();
                    if (elementType == Object) {
			Expression::ObjectCtx oCtx(
			    Expression::ObjectCtx::DOCUMENT_OK);
                        pGroupExpr = Expression::parseObject(
			    &subElement, &oCtx);
		    }
                    else if (elementType == Array) {
			uassert(15953, str::stream() <<
				"aggregating group operators are unary (" <<
				key.pName << ")", false);
                    }
                    else { /* assume its an atomic single operand */
                        pGroupExpr = Expression::parseOperand(&subElement);
                    }

                    pGroup->addAccumulator(
                        pFieldName, pOp->pFactory, pGroupExpr);
                }

		uassert(15954, str::stream() <<
			"the computed aggregate \"" <<
			pFieldName << "\" must specify exactly one operator",
			subCount == 1);
            }
        }

	uassert(15955, "a group specification must include an _id", idSet);

        return pGroup;
    }
Ejemplo n.º 17
0
void Component::printOn(std::ostream& out) {
    out << pathString();
}