Exemplo n.º 1
0
bool GLScene::load(string filename)//without extension
{
	StreamFile str(filename+".glscene",true);
	if(!str.good())return false;
	readFromStream(str);
	return true;
}
Exemplo n.º 2
0
DataDictionary::DataDictionary( std::istream& stream )
throw( ConfigError )
: m_hasVersion( false ), m_checkFieldsOutOfOrder( true ),
  m_checkFieldsHaveValues( true ), m_checkUserDefinedFields( true )
{
  readFromStream( stream );
}
Exemplo n.º 3
0
void PhysicalInStream::skipInStream(size_t size)
{
  // default implementation
  char* dummy = new char[size];
  readFromStream(dummy, size);
  delete[] dummy;
}
Exemplo n.º 4
0
void RMTony::init() {
	RMRes tony(0);
	RMRes body(9999);

	// Tony is shown by default
	_bShow = _bShowShadow = true;

	// No action pending
	_bActionPending = false;
	_bAction = false;

	_bShepherdess = false;
	_bIsTalking = false;
	_bIsStaticTalk = false;

	// Opens the buffer
	Common::SeekableReadStream *ds = tony.getReadStream();

	// Reads his details from the stream
	readFromStream(*ds, true);

	// Closes the buffer
	delete ds;

	// Reads Tony's body
	ds = body.getReadStream();
	_body.readFromStream(*ds, true);
	delete ds;
	_body.setPattern(0);

	_nTimeLastStep = g_vm->getTime();
}
Exemplo n.º 5
0
InputStream &InputStream::read(double &value)
{
	assert(streamBuffer);

	readFromStream(*streamBuffer, value);
	return *this;
}
Exemplo n.º 6
0
InputStream &InputStream::read(signed int &value)
{
	assert(streamBuffer);

	readFromStream(*streamBuffer, value);
	return *this;
}
Exemplo n.º 7
0
void Riff::readFromFile(QString fileName)
{
    QFile file(m_fileName = fileName);
    file.open(QIODevice::ReadOnly);
    QDataStream ds(&file);
    readFromStream(&ds);
    file.close();
}
Exemplo n.º 8
0
// Extract the next record from the stream leaving it in the cache for future read.
// Always call resetPointerToBegin for the extracted CFRecord after using it
CFRecordPtr CFStreamCacheReader::touchTheNextRecord()
{
	if(readFromStream(1))// make sure something is in cache
	{
		return records_cache.front();
	}
	return CFRecordPtr();
}
Exemplo n.º 9
0
void RoNetPacket::tryReadFromStream(RoDataStream& stream)
{
    roTRY
        readFromStream(stream);
    roCATCH_STD_EXCEPTION
        roLOG_CRIT << "Reading data for packet '" << mAction << "'... [FAILED]";
        roEXIT_GAME;
    roCATCH_END
}
Exemplo n.º 10
0
// Check the next record type
const CFRecordType::TypeId CFStreamCacheReader::getNextRecordType()
{
	if(isEOF())
	{
		return rt_NONE;
	}
	readFromStream(1); // I don't check the result of readFromStream() because it was done implicitly in isEOF()
	return records_cache.front()->getTypeId();
}
Exemplo n.º 11
0
size_t Sample::read(const uint8_t* const sampleStream, const size_t playhead, Sample* const target) {
    const auto next = peekIndex(sampleStream, playhead);
    size_t newPlayhead = playhead + sizeof(Sample::Index);

    if (next.typeMask & Transform::Position)
        newPlayhead = readFromStream(sampleStream, newPlayhead, &target->position);

    if (next.typeMask & Transform::Scale)
        newPlayhead = readFromStream(sampleStream, newPlayhead, &target->scale);

    if (next.typeMask & Transform::Rotation)
        newPlayhead = readFromStream(sampleStream, newPlayhead, &target->rotation);

    if (next.typeMask & Transform::Shear)
        newPlayhead = readFromStream(sampleStream, newPlayhead, &target->shear);

    if (next.typeMask & Transform::Color)
        newPlayhead = readFromStream(sampleStream, newPlayhead, &target->color);

    return newPlayhead;
}
Exemplo n.º 12
0
var var::readFromStream (InputStream& input)
{
    const int numBytes = input.readCompressedInt();

    if (numBytes > 0)
    {
        switch (input.readByte())
        {
            case varMarker_Int:         return var (input.readInt());
            case varMarker_Int64:       return var (input.readInt64());
            case varMarker_BoolTrue:    return var (true);
            case varMarker_BoolFalse:   return var (false);
            case varMarker_Double:      return var (input.readDouble());
            case varMarker_String:
            {
                MemoryOutputStream mo;
                mo.writeFromInputStream (input, numBytes - 1);
                return var (mo.toUTF8());
            }

            case varMarker_Binary:
            {
                MemoryBlock mb (numBytes - 1);

                if (numBytes > 1)
                {
                    const int numRead = input.read (mb.getData(), numBytes - 1);
                    mb.setSize (numRead);
                }

                return var (mb);
            }

            case varMarker_Array:
            {
                var v;
                Array<var>* const destArray = v.convertToArray();

                for (int i = input.readCompressedInt(); --i >= 0;)
                    destArray->add (readFromStream (input));

                return v;
            }

            default:
                input.skipNextBytes (numBytes - 1); break;
        }
    }

    return var::null;
}
Exemplo n.º 13
0
bool SerializerNew::deserializeFromStream(Variant& v, IDataStream* stream, SerializationFormat format)
{
	if (stream == nullptr)
		return false;

	auto doc = getDocument(format);

	if (!doc->readFromStream(stream))
	{
		return false;
	}

	return deserializeFromDocument(v, doc.get());
}
Exemplo n.º 14
0
const bool CFStreamCacheReader::SeekToEOF()
{
	while(readFromStream(1))
	{
		if(rt_EOF == records_cache.front()->getTypeId())
		{
			//			records_cache.pop_front(); // Skip EOF
			break;
		}
		records_cache.pop_front(); // Skip non-EOF
	}

	return true;
}
Exemplo n.º 15
0
// Check if the next read record would be of desired type
const bool CFStreamCacheReader::checkNextRecord(const CFRecordType::TypeId desirable_type, const size_t num_records_to_check)
{
	readFromStream(num_records_to_check);
	// if we would get what was requested
	// ANY_TYPE is checked just to make the fake read from stream and get an error if the stream is ended
	for(std::list<CFRecordPtr>::const_iterator it = records_cache.begin(), itEnd = records_cache.end(); it != itEnd; ++it)
	{
		size_t type = (*it)->getTypeId();
		if(desirable_type == (*it)->getTypeId() || desirable_type == CFRecordType::ANY_TYPE)
		{
			return true;
		}
	}
	return false;
}
Exemplo n.º 16
0
// Reads the next CFRecord from the CFStream and if its type is not the desired one, caches it for the next call
CFRecordPtr CFStreamCacheReader::getNextRecord(const CFRecordType::TypeId desirable_type, const bool gen_except)
{
	CFRecordType::TypeId what_we_actually_read = rt_NONE;	

	while(readFromStream(1))
	{
		CFRecordType::TypeString rec_name = records_cache.front()->getTypeString();

		//Log::warning(rec_name);

		if (desirable_type == rt_MsoDrawingGroup)	// объединяем rt_MsoDrawingGroup + rt_Continue в один блок 
		{
			if (checkNextRecord(desirable_type, 1))
			{				
				readFromStream(2);

				for(std::list<CFRecordPtr>::iterator good = records_cache.begin(), it = ++records_cache.begin();
					it != records_cache.end(); ++it, ++good)
				{
					while ((it != records_cache.end()) && (desirable_type == (*it)->getTypeId()))
					{
						(*good)->appendRawData(*it);
						records_cache.erase(it);
						if(!stream_->isEOF())
						{
							records_cache.push_back(CFRecordPtr(new CFRecord(stream_, global_info_)));
						}
						it = good;
						++it;
					}
				}
			}
		}
		
		if(0 == rec_name.length())
		{
			Log::warning(L"The extracted record has obsoleted or unknown type(0x" + STR::int2hex_wstr(records_cache.front()->getTypeId(), sizeof(CFRecordType::TypeId)) + L")");
			records_cache.pop_front();
			continue;
		}
		if(skippable_records_names.end() != std::find(skippable_records_names.begin(), skippable_records_names.end(), rec_name))
		{
			//Log::warning("The extracted record has been skipped (" + rec_name + ")");
			records_cache.pop_front();
			continue;
		}
		break;
	}

	if(0 != records_cache.size())
	{
		what_we_actually_read = records_cache.front()->getTypeId();

		// if we get what was requested
		if(desirable_type == what_we_actually_read || desirable_type == CFRecordType::ANY_TYPE)
		{
			CFRecordPtr ret = records_cache.front();
			records_cache.pop_front();
			return ret;
		}		
	}

	if(gen_except)
	{
		// теги разные
		std::string inType = XLS::CFRecordType::getStringById(desirable_type);
		std::string outType = CFRecordType::getStringById(what_we_actually_read);		

		Log::warning("The extracted record is not of requested type.\nRequested: \"" + 
			XLS::CFRecordType::getStringById(desirable_type) + "\" Extracted: \"" + CFRecordType::getStringById(what_we_actually_read) + "\"");		
	}
	return CFRecordPtr();
}
Exemplo n.º 17
0
// ######################################################################
BitObject::BitObject(std::istream& is)
{
  readFromStream(is);
}
Exemplo n.º 18
0
void SerialShell::update()
{
    readFromStream();

    if (_data[_len - 2] == '\n')
    {
        // full command received
        for (int i = 0; i < _functionCount; i++)
        {
            for (int c = 0; c < _len; c++)
            {
                if (_functions[i].command[c] == NULL
                   && (_data[c] == ' ' || _data[c] == '\n'))
                {
                    // match
                    char* newData = NULL;
                    int newDataLen = 0;
                    int nlPos = 0;
                    for (int cc = c + 1; cc < _len; cc++)
                    {
                        if (nlPos > 0)
                        {
                            newData[cc - nlPos - 1] = _data[cc];
                        }
                        else if (_data[cc] == '\n')
                        {
                            if (cc < _len - 2)
                            {
                                // multiple commands
                                nlPos = cc;
                                newDataLen = _len - cc - 1;
                                newData = new char[newDataLen + 1];
                            }

                            _data[cc] = NULL;
                        }
                    }

                    if (_data[c + 1] == NULL)
                    {
                        _functions[i].callback(_serial, NULL);
                    }
                    else
                    {
                        _functions[i].callback(_serial, _data + c + 1);
                    }

                    _len = 0;
                    delete _data;
                    _data = NULL;

                    if (newData != NULL)
                    {
                        _data = newData;
                        _len = newDataLen;
                    }
                }
                else if (_data[c] == _functions[i].command[c])
                {
                    // ok, continue
                }
                else
                {
                    // no match, go to next command
                    break;
                }
            }
        }

        flushTrash();
    }
}
Exemplo n.º 19
0
void MavlinkBridge::threadMain() {
	while (running) {
		readFromStream();
		this_thread::sleep_for(chrono::milliseconds(10));
	}
}