您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Datum函数代码示例

51自学网 2021-06-01 20:25:22
  C++
这篇教程C++ Datum函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Datum函数的典型用法代码示例。如果您正苦于以下问题:C++ Datum函数的具体用法?C++ Datum怎么用?C++ Datum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Datum函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pack

void MessagePackAdaptorTests::testString() {    // Empty    {        pack(Datum(""));        auto o = unpack();        CPPUNIT_ASSERT_EQUAL( msgpack::type::STR, o.type );        auto d = o.as<Datum>();        CPPUNIT_ASSERT( d.isString() );        CPPUNIT_ASSERT( d.stringIsCString() );        CPPUNIT_ASSERT_EQUAL( std::string(), d.getString() );    }    // Text    {        pack(Datum("abc 123"));        auto o = unpack();        CPPUNIT_ASSERT_EQUAL( msgpack::type::STR, o.type );        auto d = o.as<Datum>();        CPPUNIT_ASSERT( d.isString() );        CPPUNIT_ASSERT( d.stringIsCString() );        CPPUNIT_ASSERT_EQUAL( std::string("abc 123"), d.getString() );    }    // Data    {        const std::string value("/1/0/2/0/3/0", 6);        pack(Datum(value));        auto o = unpack();        CPPUNIT_ASSERT_EQUAL( msgpack::type::BIN, o.type );        auto d = o.as<Datum>();        CPPUNIT_ASSERT( d.isString() );        CPPUNIT_ASSERT( !d.stringIsCString() );        CPPUNIT_ASSERT_EQUAL( value, d.getString() );    }}
开发者ID:mworks,项目名称:mworks,代码行数:35,


示例2: switch

Datum ComponentRegistry::getNumber(std::string expression, GenericDataType type){  Datum value;    switch(type){      case M_FLOAT:      case M_INTEGER:      case M_BOOLEAN:      case M_STRING:          value = getValue(expression, type);          if (value.getDataType() == type) {              return value;          }          break;      default:          throw FatalParserException("Attempt to cast a number of invalid type");    }		switch (type){			case M_FLOAT:			return Datum(value.getFloat());		case M_INTEGER:			return Datum(value.getInteger());		case M_STRING:			return Datum(value.getString());		case M_BOOLEAN:			return Datum(value.getBool());		default:			return value;				}}
开发者ID:wangjing0,项目名称:mworks,代码行数:31,


示例3: cacheKey

Datum ComponentRegistry::getValue(std::string expression, GenericDataType type) {  std::pair<std::string, GenericDataType> cacheKey(expression, type);  shared_ptr<Datum> test = data_cache[cacheKey];  if(test != NULL){    return *test;  }    double doubleValue;  long longValue;  bool boolValue;  Datum value;  try {    switch(type){      case M_FLOAT:      case M_INTEGER:      case M_BOOLEAN:            doubleValue = boost::lexical_cast<double>(expression);            if (M_FLOAT == type) {                value = Datum(doubleValue);            } else if (M_INTEGER == type) {                longValue = (long)doubleValue;                if ((double)longValue != doubleValue) {                                        throw NonFatalParserException("invalid integer literal", expression.c_str());                }                value = Datum(longValue);            } else {                boolValue = (bool)doubleValue;                if ((double)boolValue != doubleValue) {                                        throw NonFatalParserException("invalid boolean literal", expression.c_str());                }                value = Datum(boolValue);            }            break;      case M_STRING:          value = Datum(string(expression));          break;      default:          // No lexical_cast for other types          break;    }        if (!value.isUndefined()) {        data_cache[cacheKey] = shared_ptr<Datum>(new Datum(value));        return value;    }  } catch (NonFatalParserException& e){      // Until we work out how to effectively flag these issues, treat them as fatal errors      throw FatalParserException(e.what());  } catch (boost::bad_lexical_cast& e){    // no biggie, we can do this the hard(er) way  }    	return Datum(ParsedExpressionVariable::evaluateExpression(expression));}
开发者ID:wangjing0,项目名称:mworks,代码行数:58,


示例4: Datum

Datum StimulusDisplay::getAnnounceData(bool updateIsExplicit) {    Datum stimAnnounce;        if (!shouldAnnounceStimuli(updateIsExplicit)) {        // No stim announcements, so just report the number of stimuli drawn        stimAnnounce = Datum(long(stimAnnouncements.size()));    } else {        stimAnnounce = Datum(M_LIST, int(stimAnnouncements.size()));        for (size_t i = 0; i < stimAnnouncements.size(); i++) {            stimAnnounce.addElement(stimAnnouncements[i]);        }    }    	return stimAnnounce;}
开发者ID:BramVerhoef,项目名称:mworks,代码行数:15,


示例5: name

void Lingo::c_varpush() {	Common::String name((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]);	Datum d;	g_lingo->_pc += g_lingo->calcStringAlignment(name.c_str());	// In immediate mode we will push variables as strings	// This is used for playAccel	if (g_lingo->_immediateMode) {		g_lingo->push(Datum(new Common::String(name)));		return;	}	if (g_lingo->getHandler(name) != NULL) {		d.type = HANDLER;		d.u.s = new Common::String(name);		g_lingo->push(d);		return;	}	d.u.sym = g_lingo->lookupVar(name.c_str());	if (d.u.sym->type == CASTREF) {		d.type = INT;		int val = d.u.sym->u.i;		delete d.u.sym;		d.u.i = val;	} else {		d.type = VAR;	}	g_lingo->push(d);}
开发者ID:AReim1982,项目名称:scummvm,代码行数:35,


示例6: Import

		/** Import */		static std::auto_ptr<DHParams> Import(const std::string& dhstr)		{			std::auto_ptr<DHParams> dh(new DHParams);			int ret = gnutls_dh_params_import_pkcs3(dh->dh_params, Datum(dhstr).get(), GNUTLS_X509_FMT_PEM);			ThrowOnError(ret, "Unable to import DH params");			return dh;		}
开发者ID:NikosPapakonstantinou,项目名称:inspircd,代码行数:8,


示例7: Datum

// ScopedVariable delegate methodsDatum ScopedVariableEnvironment::getValue(int index){	if(current_context != NULL){		return current_context->get(index);	}		// TODO: warn	return Datum();}
开发者ID:mworks,项目名称:mworks,代码行数:9,


示例8: announceData

// override of base class to provide more infoDatum DisplayBitCodeStimulus::getCurrentAnnounceDrawData() {            Datum announceData(M_DICTIONARY, 2);    announceData.addElement(STIM_NAME, getTag());        // char    announceData.addElement("bit_code",Datum((long)(*code_variable)));     return (announceData);}
开发者ID:coxlab,项目名称:coxlab_mwcore_plugins,代码行数:10,


示例9: warning

void Lingo::c_symbolpush() {	char *s = (char *)&(*g_lingo->_currentScript)[g_lingo->_pc];	g_lingo->_pc += g_lingo->calcStringAlignment(s);	warning("STUB: c_symbolpush()");	// TODO: FIXME: Must push symbol instead of string	g_lingo->push(Datum(new Common::String(s)));}
开发者ID:AReim1982,项目名称:scummvm,代码行数:9,


示例10: BOOST_STATIC_ASSERT

void MessagePackAdaptorTests::testInteger() {    constexpr auto llmin = std::numeric_limits<long long>::min();    BOOST_STATIC_ASSERT(llmin < 0);  // Sanity check    constexpr auto llmax = std::numeric_limits<long long>::max();    BOOST_STATIC_ASSERT(llmax > 0);  // Sanity check    // Negative    {        pack(Datum(llmin));        auto o = unpack();        CPPUNIT_ASSERT_EQUAL( msgpack::type::NEGATIVE_INTEGER, o.type );        auto d = o.as<Datum>();        CPPUNIT_ASSERT( d.isInteger() );        CPPUNIT_ASSERT_EQUAL( llmin, d.getInteger() );    }    // Zero    {        pack(Datum(0));        auto o = unpack();        CPPUNIT_ASSERT_EQUAL( msgpack::type::POSITIVE_INTEGER, o.type );        auto d = o.as<Datum>();        CPPUNIT_ASSERT( d.isInteger() );        CPPUNIT_ASSERT_EQUAL( 0LL, d.getInteger() );    }    // Positive    {        pack(Datum(llmax));        auto o = unpack();        CPPUNIT_ASSERT_EQUAL( msgpack::type::POSITIVE_INTEGER, o.type );        auto d = o.as<Datum>();        CPPUNIT_ASSERT( d.isInteger() );        CPPUNIT_ASSERT_EQUAL( llmax, d.getInteger() );    }    // Out of bounds    {        pack(static_cast<unsigned long long>(llmax) + 1ULL);        auto o = unpack();        CPPUNIT_ASSERT_EQUAL( msgpack::type::POSITIVE_INTEGER, o.type );        CPPUNIT_ASSERT_THROW( o.as<Datum>(), msgpack::type_error );    }}
开发者ID:mworks,项目名称:mworks,代码行数:44,


示例11: shared_data

void ExpandableListTestFixture::testAddSharedPtr(){	ExpandableList<Datum> list;		shared_ptr<Datum> shared_data(new Datum(10L));	list.addElement(shared_data);		CPPUNIT_ASSERT( list.getNElements() == 1 );	CPPUNIT_ASSERT( *(list[0]) == Datum(10L) );	}
开发者ID:mworks,项目名称:mworks,代码行数:10,


示例12: _makeString

	void _makeString(const std::string &format, va_list ap, 					 MessageType type, 					 MessageDomain domain = M_GENERIC_MESSAGE_DOMAIN) {		char buffer[MSG_BUFFER_SIZE];// = { '/0' };		int length = vsnprintf(buffer, MSG_BUFFER_SIZE, format.c_str(), ap);                // If the message is a warning or an error, append line number information (if available)        if (type >= M_WARNING_MESSAGE &&            length < MSG_BUFFER_SIZE - 1)        {            boost::shared_ptr<StateSystem> stateSystem = StateSystem::instance(false);            boost::shared_ptr<State> currentState;            if (stateSystem && (currentState = stateSystem->getCurrentState().lock())) {                int currentLineNumber = currentState->getLineNumber();                if (currentLineNumber > 0) {                    snprintf(buffer + length, MSG_BUFFER_SIZE - length, " [at line %d]", currentLineNumber);                }            }        }				if (GlobalMessageVariable) {            Datum messageDatum(M_DICTIONARY, 4);            messageDatum.addElement(M_MESSAGE_DOMAIN, Datum(M_INTEGER, domain));            messageDatum.addElement(M_MESSAGE, Datum(buffer));            messageDatum.addElement(M_MESSAGE_TYPE, Datum(M_INTEGER, type));            messageDatum.addElement(M_MESSAGE_ORIGIN, Datum(M_INTEGER, GlobalMessageOrigin));                        // Use a mutex to ensure that the set and reset happen atomically            boost::lock_guard<boost::mutex> lock(globalMessageVariableMutex);            GlobalMessageVariable->setValue(messageDatum);            GlobalMessageVariable->setSilentValue(0L);		}                // For debugging:  If the environment variable MWORKS_WRITE_MESSAGES_TO_STDERR is set,        // write the message to standard error        static int echo_to_stderr = -1;        if (echo_to_stderr < 0) {            echo_to_stderr = (NULL != getenv("MWORKS_WRITE_MESSAGES_TO_STDERR"));        }        if (echo_to_stderr) {            fprintf(stderr, "%s/n", buffer);        }	}
开发者ID:davidcox,项目名称:mworks,代码行数:43,


示例13: Datum

Datum BaseFrameListStimulus::getCurrentAnnounceDrawData() {    Datum announceData = StandardDynamicStimulus::getCurrentAnnounceDrawData();        if (stimulusGroup) {        announceData.addElement(STIMULUS_GROUP, stimulusGroup->getTag());    }        announceData.addElement(LOOP, loop->getValue());    announceData.addElement("playing", Datum(isPlaying()));        int frameNumber = getFrameNumber();    announceData.addElement("current_frame", Datum((long)frameNumber));        Datum currentStimulusAnnounceData(0L);    if ((frameNumber >= 0) && (frameNumber < getNumFrames())) {        currentStimulusAnnounceData = getStimulusForFrame(frameNumber)->getCurrentAnnounceDrawData();    }    announceData.addElement("current_stimulus", currentStimulusAnnounceData);        return announceData;}
开发者ID:mworks,项目名称:mworks,代码行数:21,


示例14: main

int main(){  Options o;  o.put("lon0",39.0);  o.put("E0",500000.0);  convs::pt2pt cnv(Datum("wgs84"), Proj("lonlat"), Options(),                  Datum("pulkovo"), Proj("tmerc"), o);  dPoint p( 39 + ((double)rand()/RAND_MAX - 0.5) * 6,    // 36..42                 ((double)rand()/RAND_MAX - 0.5) * 180); // -90..+90  printf("%.12f %.12f/n",p.x,p.y);  int i;  for (i=0; i<1000000; i++){    cnv.frw(p);    cnv.bck(p);  }  printf("%.12f %.12f/n",p.x,p.y);}
开发者ID:ushakov,项目名称:mapsoft,代码行数:21,


示例15: while

// returns a value "top", for which datums should be on the More side if t>=topint cisstCovTreeNode::SortNodeForSplit(){  int top = NData;  static int callNumber = 0;  callNumber++;  vct3 Ck; vct3 Ct;  vct3 r = F.Rotation().Row(0);  double px = F.Translation()[0];  for (int k = 0; k < top; k++) {    Ck = pMyTree->DatumSortPoint(Datum(k)); // 3D coordinate of datum in global coord system    double kx = r*Ck + px;  // compute the x coordinate in local coord system    if (kx > 0) { // this one needs to go to the end of the line      while ((--top) > k) {        Ct = pMyTree->DatumSortPoint(Datum(top));        double tx = r*Ct + px;        if (tx <= 0) {          int Temp = Datum(k);          Datum(k) = Datum(top);          Datum(top) = Temp;          break; // from the "top" loop        };      };	// end of the "t" loop    };	// end of the kx>0 case; at this point F*datum.x-coord <= 0 for i=0,...,k  };	// end of k loop  return top;}
开发者ID:mingliangfu,项目名称:IMLP,代码行数:27,


示例16: VariableProperties

void VariableTestFixture::testSimpleGlobal() {	shared_ptr<GlobalVariable>v =  global_variable_registry->createGlobalVariable( new VariableProperties(																										   new Datum(42L), "test1",																										   "Test",																										   "Test",																										   M_NEVER, M_WHEN_CHANGED,																										   true, false,																										   M_CONTINUOUS_INFINITE,""));		CPPUNIT_ASSERT((long)*v == 42);	CPPUNIT_ASSERT(v->getValue() == Datum(M_INTEGER, 42));	CPPUNIT_ASSERT(v->getVariableName() == "test1");	CPPUNIT_ASSERT(v->getLogging() == M_WHEN_CHANGED);		v->setLogging(M_NEVER);	CPPUNIT_ASSERT(v->getLogging() == M_NEVER);		v->setValue(Datum(M_INTEGER, 666));	CPPUNIT_ASSERT((long)*v == 666);		v->setValue(2112L);	CPPUNIT_ASSERT((long)*v == 2112);	}
开发者ID:davidcox,项目名称:mworks,代码行数:23,


示例17: insertInto

int insertInto(vector<string> operations){	string tableName = operations[2];	vector<Datum> data;	for(int i = 5; i < operations.size(); i++){		if( isInteger(operations[i]) == true ){			int number = atoi(operations[i].c_str());			data.push_back(Datum(number));		}		else{			data.push_back(Datum(operations[i]));		}	}	engine.insertInto(tableName,data);	return 0;}
开发者ID:jdileo4,项目名称:JohnMarianoKevin,代码行数:23,


示例18: lock

// compute the function value(s) with the current parameters//bool LinearFitableFunction::applyTheFunction(Datum *pInputData, Datum *outputData){ // DDC fixbool LinearFitableFunction::applyTheFunction(const Datum& pInputData, Datum *outputData){     lock();        if (Parameters == NULL) {        mwarning(M_SYSTEM_MESSAGE_DOMAIN,			"WARNING: Prompted for calibrated value but parameters not yet set.");        unlock(); return false;    }        //if (pInputData->getNElements() != numInputs) { // DDC fix	if (pInputData.getNElements() != numInputs) {    //        //int xxx0 = pInputData->getNElements(); // DDC fix//		int xxx0 = pInputData.getNElements();//        //double xxx1 = (double)(pInputData->getElement(0)); // DDC fix//        //double xxx2 = (double)(pInputData->getElement(1));//        double xxx1 = (double)(pInputData.getElement(0)); // DDC fix//        double xxx2 = (double)(pInputData.getElement(1));            mwarning(M_SYSTEM_MESSAGE_DOMAIN,			"WARNING: Prompted for calibrated value but not all input data exists.");        unlock(); return false;    }            double *inputDataDouble = new double [numInputs];    for (int i=0;i<numInputs;i++) {        		//inputDataDouble[i] = (double)(pInputData->getElement(i));  // copy data here // DDC fix        inputDataDouble[i] = (double)(pInputData.getElement(i));  // copy data here // DDC fix				//xxx = inputDataDouble[i];   //TODO -- remove    }        double temp = 0;    for (int p=0; p< (basisSet->getNElements()); p++) {        temp = temp + ((Parameters[p])*((basisSet->getElement(p))->applyBasis(inputDataDouble)));        //ppp = Parameters[p];    //TODO -- remove    }    *outputData = Datum(temp);//DDC edit	//*outputData = (Datum)temp;    	delete [] inputDataDouble; // DDC added	    unlock();     return true;    }
开发者ID:BramVerhoef,项目名称:mworks,代码行数:52,



注:本文中的Datum函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ DatumGetArrayTypeP函数代码示例
C++ Date函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。