本文整理汇总了C++中DataStream类的典型用法代码示例。如果您正苦于以下问题:C++ DataStream类的具体用法?C++ DataStream怎么用?C++ DataStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveContext
contextIOResultType XfemManager :: saveContext(DataStream &stream, ContextMode mode, void *obj)
{
contextIOResultType iores;
if ( mode & CM_Definition ) {
if ( !stream.write(this->numberOfEnrichmentItems) ) {
THROW_CIOERR(CIO_IOERR);
}
}
for ( int i = 1; i <= this->numberOfEnrichmentItems; i++ ) {
EnrichmentItem *object = this->giveEnrichmentItem(i);
if ( ( mode & CM_Definition ) ) {
if ( !stream.write( object->giveInputRecordName() ) ) {
THROW_CIOERR(CIO_IOERR);
}
}
if ( ( iores = object->saveContext(stream, mode) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
}
return CIO_OK;
}
示例2: saveContext
contextIOResultType MasterDof :: saveContext(DataStream &stream, ContextMode mode, void *obj)
//
// saves full node context (saves state variables, that completely describe
// current state)
//
{
contextIOResultType iores;
if ( ( iores = Dof :: saveContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( mode & CM_Definition ) {
if ( !stream.write(bc) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( !stream.write(ic) ) {
THROW_CIOERR(CIO_IOERR);
}
}
// store equation number of receiver
if ( !stream.write(equationNumber) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( ( mode & CM_UnknownDictState ) || ( dofManager->giveDomain()->giveEngngModel()->requiresUnknownsDictionaryUpdate() ) ) {
if ( ( iores = unknowns.saveContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
}
return CIO_OK;
}
示例3: restoreContext
contextIOResultType
PrimaryField :: restoreContext(DataStream &stream, ContextMode mode)
{
contextIOResultType iores(CIO_IOERR);
if ( !stream.read(actualStepNumber) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( !stream.read(actualStepIndx) ) {
THROW_CIOERR(CIO_IOERR);
}
for ( int i = 0; i <= nHistVectors; i++ ) {
if ( ( iores = solutionVectors[i].restoreYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
}
for ( int i = 0; i <= nHistVectors; i++ ) {
solStepList[i] = TimeStep(emodel);
if ( ( iores = solStepList[i].restoreContext(stream, mode) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
}
return CIO_OK;
}
示例4: saveContext
// saves full information stored in this status
// temporary variables are NOT stored
contextIOResultType
MisesMatStatus :: saveContext(DataStream &stream, ContextMode mode, void *obj)
{
contextIOResultType iores;
// save parent class status
if ( ( iores = StructuralMaterialStatus :: saveContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
// write raw data
// write plastic strain (vector)
if ( ( iores = plasticStrain.storeYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
// write cumulative plastic strain (scalar)
if ( !stream.write(kappa) ) {
THROW_CIOERR(CIO_IOERR);
}
// write damage (scalar)
if ( !stream.write(damage) ) {
THROW_CIOERR(CIO_IOERR);
}
return CIO_OK;
}
示例5: restoreContext
contextIOResultType
MisesMatStatus :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
//
// restores full information stored in stream to this Status
//
{
contextIOResultType iores;
// read parent class status
if ( ( iores = StructuralMaterialStatus :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
// read plastic strain (vector)
if ( ( iores = plasticStrain.restoreYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
// read cumulative plastic strain (scalar)
if ( !stream.read(kappa) ) {
THROW_CIOERR(CIO_IOERR);
}
// read damage (scalar)
if ( !stream.read(damage) ) {
THROW_CIOERR(CIO_IOERR);
}
return CIO_OK; // return succes
}
示例6: convRequestAvatarOutput
bool AvatarSimulation::convRequestAvatarOutput( void *vpConv ) {
DataStream ds;
spConversation conv = (spConversation)vpConv;
UUID thread;
char response;
if ( conv->response == NULL ) { // request timed out
Log.log( 0, "AvatarSimulation::convRequestAvatarOutput: request timed out" );
return 0; // end conversation
}
ds.setData( conv->response, conv->responseLen );
ds.unpackUUID( &thread ); // thread
response = ds.unpackChar();
this->ds.unlock();
if ( response == 0 ) { // success
STATE(AvatarSimulation)->simRegistrationConfirmed = true;
this->parseAvatarOutput( &ds );
} else { // failure
// avatar doesn't exist? nothing to do
}
return 0;
}
示例7: restoreContext
contextIOResultType Lattice2d :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
{
contextIOResultType iores;
if ( ( iores = LatticeStructuralElement :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( mode & CM_Definition ) {
if ( !stream.read(width) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( !stream.read(thickness) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( !stream.read(couplingFlag) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( ( iores = couplingNumbers.restoreYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( ( iores = gpCoords.restoreYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
}
return CIO_OK;
}
示例8: assert
int LuaScriptEngine::Compiler::writer(lua_State* L, const void* p, size_t size, void* data)
{
(void)L;
assert( data );
DataStream* s = static_cast<DataStream*>(data);
return (s->write(p, size) != size) && (size != 0);
}
示例9: year
DatePackage::DatePackage(const sigset_t &mask, const bool &cancel, size_t &length, DataStream &stream):
year(stream.read_int16(mask, cancel, length)),
month(stream.read_uint8(mask, cancel, length)),
day(stream.read_uint8(mask, cancel, length))
{
}
示例10: restoreContext
contextIOResultType XfemManager :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
{
contextIOResultType iores;
if ( mode & CM_Definition ) {
if ( !stream.read(this->numberOfEnrichmentItems) ) {
THROW_CIOERR(CIO_IOERR);
}
this->enrichmentItemList.resize(this->numberOfEnrichmentItems);
}
for ( int i = 1; i <= this->numberOfEnrichmentItems; i++ ) {
EnrichmentItem *obj;
if ( mode & CM_Definition ) {
std :: string name;
if ( !stream.read(name) ) {
THROW_CIOERR(CIO_IOERR);
}
std :: unique_ptr< EnrichmentItem >ei( classFactory.createEnrichmentItem(name.c_str(), i, this, this->domain) );
obj = ei.get();
enrichmentItemList.insert( enrichmentItemList.begin() + i - 1, std :: move(ei) );
} else {
obj = this->giveEnrichmentItem(i);
}
if ( ( iores = obj->restoreContext(stream, mode) ) != CIO_OK ) {
THROW_CIOERR(CIO_IOERR);
}
}
return CIO_OK;
}
示例11: serialize
void ASCPongPackage::serialize(const sigset_t &mask, const bool& cancel, DataStream &stream, bool with_header) const
{
if (with_header){
stream.write_uint8(mask, cancel, get_type());
stream.write_uint32(mask, cancel, get_ser_size());
}
}
示例12: saveContext
contextIOResultType SimpleSlaveDof :: saveContext(DataStream &stream, ContextMode mode, void *obj)
//
// saves full node context (saves state variables, that completely describe
// current state)
//
{
contextIOResultType iores;
if ( ( iores = Dof :: saveContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( mode & CM_Definition ) {
if ( mode & CM_DefinitionGlobal ) {
int _masterGlobNum = dofManager->giveDomain()->giveDofManager(masterDofMngr)->giveGlobalNumber();
if ( !stream.write(_masterGlobNum) ) {
THROW_CIOERR(CIO_IOERR);
}
} else {
if ( !stream.write(masterDofMngr) ) {
THROW_CIOERR(CIO_IOERR);
}
}
}
return CIO_OK;
}
示例13: saveContext
contextIOResultType
PlasticMaterialStatus :: saveContext(DataStream &stream, ContextMode mode, void *obj)
//
// saves full information stored in this Status
// no temp variables stored
//
{
contextIOResultType iores;
// save parent class status
if ( ( iores = StructuralMaterialStatus :: saveContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
// write a raw data
if ( ( iores = plasticStrainVector.storeYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( ( iores = strainSpaceHardeningVarsVector.storeYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( !stream.write(state_flag) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( !stream.write(gamma) ) {
THROW_CIOERR(CIO_IOERR);
}
return CIO_OK;
}
示例14: restoreContext
contextIOResultType
PlasticMaterialStatus :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
//
// restores full information stored in stream to this Status
//
{
contextIOResultType iores;
// read parent class status
if ( ( iores = StructuralMaterialStatus :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( ( iores = plasticStrainVector.restoreYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( ( iores = strainSpaceHardeningVarsVector.restoreYourself(stream) ) != CIO_OK ) {
THROW_CIOERR(iores);
}
if ( !stream.read(state_flag) ) {
THROW_CIOERR(CIO_IOERR);
}
if ( !stream.read(gamma) ) {
THROW_CIOERR(CIO_IOERR);
}
return CIO_OK; // return success
}
示例15: loop
void loop() {
static int disconnected;
console.printf("HELLO?\r\n");
if (millis() - lastCheck > 3000) {
digitalWrite(RED_LED,LED_OFF);
if ((! hasWifiModule) || networkStatus()) {
digitalWrite(RED_LED,LED_OFF);
disconnected=0;
} else {
digitalWrite(RED_LED,LED_ON);
if (++disconnected > 10) {
char tempssid[40];
strcpy(tempssid,networkSSID);
digitalWrite(RED_LED,networkJoin(tempssid)?LED_OFF:LED_ON);
}
}
digitalWrite(GRN_LED,SerialUSB.isConnected()?HIGH:LOW);
lastCheck=millis();
}
while (console.gotLine()) {
digitalWrite(GRN_LED,LOW);
handleConsoleInput();
digitalWrite(GRN_LED,HIGH);
}
clearStowedValues();
Watchdog_Reset();
}