shared_ptr<Predicate<EdgeId>> ParseConjunction(size_t& min_length_bound,
                                                double& min_coverage_bound) {
     shared_ptr<Predicate<EdgeId>> answer =
             make_shared<AlwaysTrue<EdgeId>>();
     VERIFY(next_token_ == "{");
     ReadNext();
     while (next_token_ != "}") {
         answer = make_shared<AndOperator<EdgeId>>(
             answer,
             ParseCondition(min_length_bound, min_coverage_bound));
         ReadNext();
     }
     return answer;
 }
Example #2
0
void CqShaderVM::SO_external()
{
	AUTOFUNC;
	SqDSOExternalCall *pCall = ReadNext().m_pExtCall;
	// This is a little ugly, but it means we can still use RESULT with Voids.
	RESULT( (pCall->return_type != type_void ? pCall->return_type : type_float) , class_varying);

	SqStackEntry *stackitems = new SqStackEntry[pCall->arg_types.size()];
	IqShaderData **arg_data = new IqShaderData*[pCall->arg_types.size()];
	unsigned int x = 0;
	for ( x = 0 ; x < pCall->arg_types.size();x++)
	{
		stackitems[x] = POP;
		arg_data[x] = stackitems[x].m_Data;
	};

	if(m_pEnv->IsRunning())
		m_pEnv->SO_external(pCall->method, pCall->initData, pResult, this, pCall->arg_types.size(),arg_data);

	for ( x = 0 ; x < pCall->arg_types.size();x++)
	{
		Release( stackitems[x] );
	};

	delete[]( stackitems );
	delete[]( arg_data );

	Push( pResult );
}
Example #3
0
int GDALJP2Box::ReadNextChild( GDALJP2Box *poSuperBox )

{
    if( poSuperBox == NULL )
        return ReadNext();

    if( !ReadNext() )
        return FALSE;

    if( nBoxOffset >= poSuperBox->nBoxOffset + poSuperBox->nBoxLength )
    {
        szBoxType[0] = '\0';
        return FALSE;
    }

    return TRUE;
}
Example #4
0
void
DirectParser::ParseOld     (QXmlStreamReader & xread, 
                            DirectMessage    & msg,
                            qint64           & offset,
                            bool             & complete,
                            bool             & good)
{
  QXmlStreamReader::TokenType tokt = ReadNext (xread);
  QXmlStreamAttributes atts;
  msg.SetOp ("xmpp");
  msg.SetSubop ("msg");
  ReadNext (xread); // eat the characters
  ReadNext (xread); // eat the end-element
  offset = xread.characterOffset ();
  QByteArray data = inbuf.buffer().left (offset);
  msg.SetData (data);
  complete = true;
  good = true;
}
Example #5
0
void CqShaderVM::SO_rayinfo()
{
	AUTOFUNC;
	IqShaderData* pV = GetVar( ReadNext().m_iVariable );
	POPV( DataInfo );
	RESULT(type_float, __fVarying?class_varying:class_uniform);
	if(m_pEnv->IsRunning())
		m_pEnv->SO_rayinfo( DataInfo, pV, pResult );
	Push( pResult );
}
Example #6
0
File: dmerge.C Project: herf/dmerge
    void OpenFile(char *name) {
#if FOPEN64
        in = fopen64(name, "r");
#else
        in = fopen(name, "r");
#endif
        date = -1;
        if (in == NULL) date = 0;
        ReadNext();
    }
Example #7
0
bool CGwsFlatGwsIterator::NextFeature (IGWSFeature ** feature)
{
    if (feature != NULL) {
        if (ReadNext ()) {
            * feature = this;
            AddRef ();
            return true;
        }
    }
    return false;
}
Example #8
0
void CqShaderVM::SO_opposite()
{
	AUTOFUNC;
	IqShaderData* pV = GetVar( ReadNext().m_iVariable );
	POPV( Val );
	RESULT(type_float, __fVarying?class_varying:class_uniform);
	if(m_pEnv->IsRunning())
		m_pEnv->SO_opposite( Val, pV, pResult );
	Push( pResult );
	RELEASE( Val );
}
Example #9
0
void
DirectParser::ParseSendfile (QXmlStreamReader & xread, 
                            DirectMessage    & msg,
                            qint64           & offset,
                            bool             & complete,
                            bool             & good,
                            QXmlStreamAttributes & atts)
{
  QString subop = atts.value("subop").toString().toLower();
  msg.SetSubop (subop);
  bool valid (false);
  if (subop == "chunk-data") {
    ReadNext (xread);
    if (xread.isCharacters ()) {
      msg.SetData (xread.text().toString().toUtf8());
      valid = true;
      ReadNext (xread);
    }
    offset = xread.characterOffset ();
  } else {
    valid= ( subop == "sendreq"
          || subop == "samreq"
          || subop == "goahead"
          || subop == "deny"
          || subop == "chunk-ack"
          || subop == "snd-done"
          || subop == "abort"
           );
    ReadNext (xread);
  }
  if (valid) {
    for (int i=0; i< atts.size(); i++) {
      msg.SetAttribute (atts[i].name().toString().toLower(),
                        atts[i].value().toString());
    }
    good = true;
    complete = true;
    offset = xread.characterOffset ();
  } 
}
Example #10
0
//-----------------------------------------------------------------------------
// Purpose: Reads the current chunk and dispatches keys and sub-chunks to the
//			appropriate handler callbacks.
// Input  : pfnKeyHandler - Callback for any key values in this chunk.
//			pData - Data to pass to the key value callback function.
// Output : Normally returns ChunkFile_Ok or ChunkFile_EOF. Otherwise, returns
//			a ChunkFile_xxx error code.
//-----------------------------------------------------------------------------
ChunkFileResult_t CChunkFile::ReadChunk(KeyHandler_t pfnKeyHandler, void *pData)
{
	//
	// Read the keys and sub-chunks.
	//
	ChunkFileResult_t eResult;
	do
	{
		char szName[MAX_KEYVALUE_LEN];
		char szValue[MAX_KEYVALUE_LEN];
		ChunkType_t eChunkType;

		eResult = ReadNext(szName, szValue, sizeof(szValue), eChunkType);

		if (eResult == ChunkFile_Ok)
		{
			if (eChunkType == ChunkType_Chunk)
			{
				//
				// Dispatch sub-chunks to the appropriate handler.
				//
				eResult = HandleChunk(szName);
			}
			else if ((eChunkType == ChunkType_Key) && (pfnKeyHandler != NULL))
			{
				//
				// Dispatch keys to the key value handler.
				//
				eResult = pfnKeyHandler(szName, szValue, pData);
			}
		}
	} while (eResult == ChunkFile_Ok);

	//
	// Cover up ChunkFile_EndOfChunk results because the caller doesn't want to see them.
	//
	if (eResult == ChunkFile_EndOfChunk)
	{
		eResult = ChunkFile_Ok;
	}

	//
	// Dispatch errors to the handler.
	//
	if ((eResult != ChunkFile_Ok) && (eResult != ChunkFile_EOF))
	{
		//HandleError("chunkname", eResult);
	}

	return(eResult);
}
Example #11
0
void
DirectParser::ParseXmpp (QXmlStreamReader & xread, 
                            DirectMessage    & msg,
                            qint64           & offset,
                            bool             & complete,
                            bool             & good,
                            QXmlStreamAttributes & atts)
{
  QString subop = atts.value("subop").toString().toLower();
  msg.SetSubop (subop);
  if (subop == "msg") {
    complete = true; good = true;
  }
  ReadNext (xread);
  if (xread.isCharacters()) {
    msg.SetData (xread.text().toString().toUtf8());
    ReadNext (xread);
  }
  offset = xread.characterOffset ();
  if (xread.tokenType() != QXmlStreamReader::EndElement) {
    complete = false; good = false;
  }
}
/// </summary> Reads in the next block of items. Use ReadNext( buffer) to read in 
/// the entire stream. The caller is responsible to create/dispose the FdoArray. </summary>
/// <param name="buffer"> FdoArray object holding data read in. Cannot be NULL </param> 
/// <param name="offset"> Index in the array indicating the beginning of the output buffer. 
/// If the end of the buffer, then read in appending mode (store at the end). 
/// Otherwise, overwrite the buffer. Throws "invalid parameter" exception if not in this range.</param> 
/// <param name="count">  Number of items to be read in. If -1 read the entire stream.
///  Throws "invalid parameter"  exception if not a positive value or -1.</param> 
/// <returns> Returns number of items read.</returns> 
FdoInt32 FdoRfpStreamReaderGdalByTile::ReadNext(  FdoArray<FdoByte> * &buffer, 
                                        const FdoInt32 offset,
                                        const FdoInt32 count)
{
    if (count < -1 || offset < 0)
        throw FdoException::Create(FdoException::NLSGetMessage(FDO_2_BADPARAMETER, "Bad parameter to method."));

    FdoInt32 countToRead = (FdoInt32)(count == -1 ? GetLength() - GetIndex() : count);
    // resize the buffer if necessary
    buffer = FdoArray<FdoByte>::Create(offset + countToRead);

    return ReadNext(buffer->GetData(), offset, count);

}
Example #13
0
File: dmerge.C Project: herf/dmerge
    void ReadNext() {
        if (!date) return;

        if (feof(in)) {
            date = 0;
            return;
        }

        buf[0] = 0;
        fgets(buf, 4096, in);

        // eliminate monitor scripts :)
        if (strstr(buf, "monitor")) {
            ReadNext();
            return;
        }

        char *time = strchr(buf, '[');

        if (!time) {
            ReadNext();
            return;
        }

        time ++;
        char *end = strchr(time, ' ');
        if (!end) {
            ReadNext();
            return;
        }

        // copy from time to end into datebuf
        strncpy(datebuf, time, end - time);
        datebuf[end - time] = 0;

        date = WebTime(datebuf);
    };
Example #14
0
//读取超时处理,再次读取,总次数不超过3次
void TIM2_IRQHandler(void)
{
	if(TIM_GetITStatus(TIM2,TIM_IT_Update) != RESET)
	{
		ReadTime++;
		if(ReadTime<=1) 
		{
			ReadOffSet();
			Usart1Send();
		}
		else //判断为故障
		{	
			switch(Net_Sel)
			{
				case 1:
									NetState[0] = 2;
									MMSI[0] = 0;
									break;
				case 2:
									NetState[1] = 2;
									MMSI[1] = 0;
									break;
				case 3:
									NetState[2] = 2;
									MMSI[2] = 0;
									break;	
			}
			if(FirstReadFlag==0) //不是第一次读取
			{
				TIM_Cmd(TIM2,DISABLE);
			}
			else  //第一次读取
			{
				Net_Sel++;
				if(Net_Sel<=3) //继续读取下一个
				{
					ReadNext();
				}
				else //三个网位仪都读取完
				{
					TIM_Cmd(TIM2,DISABLE);
					FirstReadFlag = 0;
				}
				ReadTime = 0;
			}
		}
		TIM_ClearITPendingBit(TIM2,TIM_IT_Update);
	}
}
Example #15
0
void
DirectParser::ParseCtl (QXmlStreamReader & xread, 
                            DirectMessage    & msg,
                            qint64           & offset,
                            bool             & complete,
                            bool             & good,
                            QXmlStreamAttributes & atts)
{
  QString subop = atts.value("subop").toString().toLower();
  msg.SetSubop (subop);
  if (subop == "heartbeat") {
    complete = true;
    good = true;
  }
  ReadNext (xread);
}
Example #16
0
void Datum::Reader::ReadList() {
    std::unique_ptr<List> l(new List);
    Cursor += 1;
    Deblank();
    while(*Cursor != ')') {
        ReadNext();
        if(Errors.size() > 0)
            break;
        l->Data.push_back(Red.release());
        Deblank(); }

    if(*Cursor == ')') {
        Cursor += 1;
        Red.reset(l.release()); }

    return; }
Example #17
0
 bool ConfigSections::ReadNext(std::string& name,std::string& value) {
   if(!ReadNext(name)) return false;
   std::string::size_type n = name.find('=');
   if(n == std::string::npos) { value=""; return true; };
   value=name.c_str()+n+1;
   name.erase(n);
   std::string::size_type l = value.length();
   for(n = 0;n<l;n++) if((value[n] != ' ') && (value[n] != '\t')) break;
   if(n>=l) { value=""; return true; };
   if(n) value.erase(0,n);
   if(value[0] != '"') return true;
   std::string::size_type nn = value.rfind('"');
   if(nn == 0) return true; // strange
   std::string::size_type n_ = value.find('"',1);
   if((nn > n_) && (n_ != 1)) return true;
   value.erase(nn);
   value.erase(0,1);
   return true;
 }
Example #18
0
bool
DirectParser::Read (DirectMessage & msg)
{
  msg.Clear ();
  if (!bufLock.tryLock (5000)) {
    qDebug () << "WARNING: Mutex locked 5 seconds, giving up";
    return false;
  }
  QXmlStreamReader              xread (&inbuf);
  QXmlStreamReader::TokenType   tokt;
  bool finished (false);
  bool complete (false);
  bool good (false);
  bool badData (false);
  QString  topname;
  QString  bottomtag;
  QString  version;
  qint64 offset (0);
  while (!finished) {
    tokt = ReadNext (xread);
    offset = xread.characterOffset ();
    qDebug () << " Direct token " << xread.tokenString();
    switch (tokt) {
    case QXmlStreamReader::NoToken :
      qDebug () << " no token found";
      finished = true; complete = false; good = false;
      lastErr = Proto_EmptyInput;
      break;
    case QXmlStreamReader::Invalid :
      qDebug () << " bad token";
      qDebug () << " text until here: " << inbuf.buffer().left(offset);
    
      finished = true; complete = false; good = false;
      lastErr = Proto_BadTag;
      badData = true;
      break;
    case QXmlStreamReader::StartElement:
      topname = xread.name().toString().toLower();
      if (topname == oldTopTag) {
        ParseOld (xread, msg, offset, complete, good);
        msg.SetAttribute ("version","0.1");
      } else if (topname == topTag) {
        version = xread.documentVersion ().toString();
        msg.SetAttribute ("version",version);
        ParseMessage (xread, msg, offset, complete, good);
      } else {
qDebug () << " topname unknown: " << topname;
        finished = true;  complete = false; good = false;
        lastErr = Proto_WrongProtocol;
      }
      break;
    case QXmlStreamReader::EndElement:
      bottomtag = xread.name().toString().toLower();
      if (bottomtag == topname) {
        finished = true;
      }
      break;
    case QXmlStreamReader::EndDocument :
      finished = true;
      break;
    case QXmlStreamReader::Characters:
      break;
    case QXmlStreamReader::StartDocument:
    case QXmlStreamReader::Comment:
    case QXmlStreamReader::DTD:
    case QXmlStreamReader::EntityReference:
    case QXmlStreamReader::ProcessingInstruction:
      break;
    default:
      qDebug () << " unknown token type " << tokt;
      lastErr = Proto_Unknown;
      finished = true; complete = false; good = false;
      break;
    }
  }
    if (good && complete) {
    /// we have consumed a message, so get rid of the raw data
    /// so we can read the next message next time   
    qDebug () << " trailing token " << xread.tokenString ();
    while (!xread.atEnd() && xread.tokenType() != QXmlStreamReader::EndDocument) {
      xread.readNext();
      qDebug () << " consumed " << xread.tokenString ();
    }
    qDebug () << " remove " << offset << " bytes from buffer: ";
    qDebug () << inbuf.buffer().left(offset);
    inbuf.buffer().remove (0,offset+1);
    inbuf.seek (0);
  } else {
    msg.Clear ();
  }
  qDebug () << " after DirectParser::Read buffer has [[" << inbuf.buffer() << "]]";
  qDebug () << " token " << xread.tokenString() << " error " << xread.error();
  if (!good) {
    if (xread.error () == QXmlStreamReader::PrematureEndOfDocumentError) {
      complete = false;
      good = true;
    }
  }
  lastComplete = complete;
  lastGood = good;
  bufLock.unlock ();
  return good && complete;
}
    shared_ptr<Predicate<EdgeId>> ParseCondition(size_t& min_length_bound,
                                                 double& min_coverage_bound) {
        if (next_token_ == "tc_lb") {
            double length_coeff = lexical_cast<double>(ReadNext());

            DEBUG("Creating tip length bound. Coeff " << length_coeff);
            size_t length_bound = LengthThresholdFinder::MaxTipLength(
                settings_.read_length(), g_.k(), length_coeff);

            DEBUG("Length bound" << length_bound);

            RelaxMin(min_length_bound, length_bound);
            return make_shared<LengthUpperBound<Graph>>(g_, length_bound);
        } else if (next_token_ == "to_ec_lb") {
            double length_coeff = lexical_cast<double>(ReadNext());

            DEBUG( "Creating length bound for erroneous connections originated from tip merging. Coeff " << length_coeff);
            size_t length_bound =
                    LengthThresholdFinder::MaxTipOriginatedECLength(
                        settings_.read_length(), g_.k(), length_coeff);

            DEBUG("Length bound" << length_bound);

            RelaxMin(min_length_bound, length_bound);
            return make_shared<LengthUpperBound<Graph>>(g_, length_bound);
        } else if (next_token_ == "ec_lb") {
            size_t length_coeff = lexical_cast<size_t>(ReadNext());

            DEBUG("Creating ec length bound. Coeff " << length_coeff);
            size_t length_bound =
                    LengthThresholdFinder::MaxErroneousConnectionLength(
                        g_.k(), length_coeff);

            RelaxMin(min_length_bound, length_bound);
            return make_shared<LengthUpperBound<Graph>>(g_, length_bound);
        } else if (next_token_ == "lb") {
            size_t length_bound = lexical_cast<size_t>(ReadNext());

            DEBUG("Creating length bound. Value " << length_bound);

            RelaxMin(min_length_bound, length_bound);
            return make_shared<LengthUpperBound<Graph>>(g_, length_bound);
        } else if (next_token_ == "cb") {
            ReadNext();
            double cov_bound = GetCoverageBound();
            DEBUG("Creating coverage upper bound " << cov_bound);
            RelaxMin(min_coverage_bound, cov_bound);
            return make_shared<CoverageUpperBound<Graph>>(g_, cov_bound);
        } else if (next_token_ == "icb") {
            ReadNext();
            double cov_bound = GetCoverageBound();
            cov_bound = cov_bound / (double) settings_.iteration_count() * (double) (settings_.iteration() + 1);
            DEBUG("Creating iterative coverage upper bound " << cov_bound);
            RelaxMin(min_coverage_bound, cov_bound);
            return make_shared<CoverageUpperBound<Graph>>(g_, cov_bound);
        } else if (next_token_ == "rctc") {
            ReadNext();
            DEBUG("Creating relative cov tip cond " << next_token_);
            return make_shared<RelativeCoverageTipCondition<Graph>>(
                g_, lexical_cast<double>(next_token_));
        } else if (next_token_ == "disabled") {
            DEBUG("Creating disabling condition");
            return make_shared<func::AlwaysFalse<EdgeId>>();
        } else {
            VERIFY(false);
            return make_shared<func::AlwaysTrue<EdgeId>>();
        }
    }
Example #20
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : ChunkFileResult_t
//-----------------------------------------------------------------------------
ChunkFileResult_t CChunkFile::HandleChunk(const char *szChunkName)
{
	// See if the default handler wants it?
	if( m_DefaultChunkHandler )
	{
		ChunkFileResult_t testResult = m_DefaultChunkHandler( this, m_pDefaultChunkHandlerData, szChunkName );
		if( testResult == ChunkFile_Ok )
		{
			return ChunkFile_Ok;
		}
	}

	//
	// If there is an active handler map...
	//
	if (m_nHandlerStackDepth > 0)
	{
		CChunkHandlerMap *pHandler = m_HandlerStack[m_nHandlerStackDepth - 1];

		//
		// If a chunk handler was found in the handler map...
		//
		void *pData;
		ChunkHandler_t pfnHandler = pHandler->GetHandler(szChunkName, &pData);
		if (pfnHandler != NULL)
		{
			// Dispatch this chunk to the handler.
			ChunkFileResult_t eResult = pfnHandler(this, pData);
			if (eResult != ChunkFile_Ok)
			{
				return(eResult);
			}
		}
		else
		{
			//
			// No handler for this chunk. Skip to the matching close curly brace.
			//
			int nDepth = 1;
			ChunkFileResult_t eResult;

			do
			{
				ChunkType_t eChunkType;
				char szKey[MAX_KEYVALUE_LEN];
				char szValue[MAX_KEYVALUE_LEN];

				while ((eResult = ReadNext(szKey, szValue, sizeof(szValue), eChunkType)) == ChunkFile_Ok)
				{
					if (eChunkType == ChunkType_Chunk)
					{
						nDepth++;
					}
				}

				if (eResult == ChunkFile_EndOfChunk)
				{
					eResult = ChunkFile_Ok;
					nDepth--;
				}
				else if (eResult == ChunkFile_EOF)
				{
					return(ChunkFile_UnexpectedEOF);
				}

			} while ((nDepth) && (eResult == ChunkFile_Ok));
		}
	}
	
	return(ChunkFile_Ok);
}
bool PdfContentsTokenizer::ReadNext( EPdfContentsType& reType, const char*& rpszKeyword, PdfVariant & rVariant )
{
    EPdfTokenType eTokenType;
    EPdfDataType  eDataType;
    const char*   pszToken;

    // While officially the keyword pointer is undefined if not needed, it
    // costs us practically nothing to zero it (in case someone fails to check
    // the return value and/or reType). Do so. We won't nullify the variant
    // since that has a real cost.
    //rpszKeyword = 0;

    // If we've run out of data in this stream and there's another one to read,
    // switch to reading the next stream.
    //if( m_device.Device() && m_device.Device()->Eof() && m_lstContents.size() )
    //{
    //    SetCurrentContentsStream( m_lstContents.front() );
    //    m_lstContents.pop_front();
    //}

    bool gotToken = this->GetNextToken( pszToken, &eTokenType );
    if ( !gotToken )
    {
        if ( m_lstContents.size() )
        {
	    // We ran out of tokens in this stream. Switch to the next stream
	    // and try again.
            SetCurrentContentsStream( m_lstContents.front() );
            m_lstContents.pop_front();
            return ReadNext( reType, rpszKeyword, rVariant );
        }
        else
        {
            // No more content stream tokens to read.
            return false;
        }
    }

    eDataType = this->DetermineDataType( pszToken, eTokenType, rVariant );

    // asume we read a variant unless we discover otherwise later.
    reType = ePdfContentsType_Variant;

    switch( eDataType ) 
    {
        case ePdfDataType_Null:
        case ePdfDataType_Bool:
        case ePdfDataType_Number:
        case ePdfDataType_Real:
            // the data was already read into rVariant by the DetermineDataType function
            break;

        case ePdfDataType_Reference:
        {
            // references are invalid in content streams
            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "references are invalid in content streams" );
            break;
        }

        case ePdfDataType_Dictionary:
            this->ReadDictionary( rVariant, NULL );
            break;
        case ePdfDataType_Array:
            this->ReadArray( rVariant, NULL );
            break;
        case ePdfDataType_String:
            this->ReadString( rVariant, NULL );
            break;
        case ePdfDataType_HexString:
            this->ReadHexString( rVariant, NULL );
            break;
        case ePdfDataType_Name:
            this->ReadName( rVariant );
            break;

        case ePdfDataType_Unknown:
        case ePdfDataType_RawData:
        default:
            // Assume we have a keyword
            reType     = ePdfContentsType_Keyword;
            rpszKeyword = pszToken;
            break;
    }
    return true;
}
FdoInt32 SuperMapStreamReader::ReadNext(  FdoArray<FdoByte> * &buffer, const FdoInt32 offset, const FdoInt32 count )
{
	TRACE(_T("调用 SuperMapStreamReader::ReadNext(FdoArray)... \n"));
	return ReadNext(buffer->GetData(), offset, count);
}
Example #23
0
XnStatus PlayerNode::SeekToFrameAbsolute(XnUInt32 nNodeID, XnUInt32 nDestFrame)
{
	XN_ASSERT((nNodeID != INVALID_NODE_ID) && (nNodeID < m_nMaxNodes));
	PlayerNodeInfo* pPlayerNodeInfo = &m_pNodeInfoMap[nNodeID];
	XN_ASSERT((nDestFrame > 0) && (nDestFrame <= pPlayerNodeInfo->nFrames));
	XN_VALIDATE_INPUT_PTR(m_pNodeNotifications);

	XnStatus nRetVal = XN_STATUS_OK;

	if (nDestFrame == pPlayerNodeInfo->nCurFrame)
	{
		//Just go back to position of current frame
		nRetVal = SeekStream(XN_OS_SEEK_SET, pPlayerNodeInfo->nLastDataPos);
		XN_IS_STATUS_OK(nRetVal);

		return XN_STATUS_OK;
	}

	DataIndexEntry** pDataIndex = GetSeekLocationsFromDataIndex(nNodeID, nDestFrame);
	if (pDataIndex != NULL)
	{
		XnUInt32 nLastPos = 0;

		// move each node to its relevant data
		for (XnUInt32 i = 0; i < m_nMaxNodes; i++)
		{
			if (m_pNodeInfoMap[i].bIsGenerator)
			{
				// read data
				nRetVal = SeekStream(XN_OS_SEEK_SET, m_aSeekTempArray[i]->nSeekPos);
				XN_IS_STATUS_OK(nRetVal);
				nRetVal = ReadNext();
				XN_IS_STATUS_OK(nRetVal);

				XnUInt32 nPos = TellStream();
				if (nPos > nLastPos)
				{
					nLastPos = nPos;
				}
			}
		}
	}
	else
	{
		// perform old seek
		XnUInt32 nStartPos = TellStream();
		XnUInt32 nNextFrame = pPlayerNodeInfo->nCurFrame + 1;
		XnUInt32 nFrames = pPlayerNodeInfo->nFrames;
		XnStatus nRetVal = XN_STATUS_OK;

		if (nDestFrame == pPlayerNodeInfo->nCurFrame)
		{
			//Just go back to position of current frame
			nRetVal = SeekStream(XN_OS_SEEK_SET, pPlayerNodeInfo->nLastDataPos);
			XN_IS_STATUS_OK(nRetVal);
		}
		else if (nDestFrame < nNextFrame)
		{
			//Seek backwards
			XnUInt32 nDestRecordPos = pPlayerNodeInfo->newDataUndoInfo.nRecordPos;
			XnUInt32 nUndoRecordPos = pPlayerNodeInfo->newDataUndoInfo.nUndoRecordPos;
			NewDataRecordHeader record(m_pRecordBuffer, RECORD_MAX_SIZE);
			
			/*Scan back through the frames' undo positions until we get to a frame number that is smaller or equal
			  to nDestFrame. We put the position of the frame we find in nDestRecordPos. */
			do
			{
				if (nUndoRecordPos == 0)
				{
					/* The last frame we encountered doesn't have an undo frame. But this data frame can't be the first,
					   so the file is corrupt */
					XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Undo frame not found for frame in position %u", nDestRecordPos);
				}
				nRetVal = SeekStream(XN_OS_SEEK_SET, nUndoRecordPos);
				XN_IS_STATUS_OK(nRetVal);
				nDestRecordPos = nUndoRecordPos;
				record.ResetRead();
				nRetVal = ReadRecordHeader(record);
				XN_IS_STATUS_OK(nRetVal);
				if (record.GetType() != RECORD_NEW_DATA)
				{
					XN_ASSERT(FALSE);
					XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Unexpected record type: %u", record.GetType());
				}

				if (record.GetNodeID() != nNodeID)
				{
					XN_ASSERT(FALSE);
					XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Unexpected node id: %u", record.GetNodeID());
				}

				nRetVal = ReadRecordFields(record);
				XN_IS_STATUS_OK(nRetVal);
				nRetVal = record.Decode();
				XN_IS_STATUS_OK(nRetVal);
				nUndoRecordPos = record.GetUndoRecordPos();
			} while (record.GetFrameNumber() > nDestFrame);

			//Now handle the frame
			nRetVal = HandleNewDataRecord(record, FALSE);
			XnBool bUndone = FALSE;

			for (XnUInt32 i = 0; i < m_nMaxNodes; i++)
			{
				//Rollback all properties to match the state the stream was in at position nDestRecordPos
				PlayerNodeInfo &pni = m_pNodeInfoMap[i];
				for (RecordUndoInfoMap::Iterator it = pni.recordUndoInfoMap.begin(); 
					 it != pni.recordUndoInfoMap.end(); it++)
				{
					if ((it.Value().nRecordPos > nDestRecordPos) && (it.Value().nRecordPos < nStartPos))
					{
						//This property was set between nDestRecordPos and our start position, so we need to undo it.
						nRetVal = UndoRecord(it.Value(), nDestRecordPos, bUndone);
						XN_IS_STATUS_OK(nRetVal);
					}
				}

				if ((i != nNodeID) && pni.bIsGenerator)
				{
					//Undo all other generator nodes' data
					RecordUndoInfo &undoInfo = pni.newDataUndoInfo;
					if ((undoInfo.nRecordPos > nDestRecordPos) && (undoInfo.nRecordPos < nStartPos))
					{
						nRetVal = UndoRecord(undoInfo, nDestRecordPos, bUndone);
						XN_IS_STATUS_OK(nRetVal);
						if (!bUndone)
						{
							//We couldn't find a record that can undo this data record
							pni.nLastDataPos = 0;
							pni.newDataUndoInfo.Reset();
						}
					}
				}
			}

			/*Now, for each node, go to the position of the last encountered data record, and process that record
			  (including its payload).*/
			/*TODO: Optimization: remember each node's last data pos, and later, see if it changes. Only process data
			  frames of nodes whose last data pos actually changed.*/

			nRetVal = ProcessEachNodeLastData(nNodeID);
			XN_IS_STATUS_OK(nRetVal);
		}
		else //(nDestFrame >= nNextFrame)
		{
			//Skip all frames until we get to our frame number, but handle any properties we run into.
			while (pPlayerNodeInfo->nCurFrame < nDestFrame)
			{
				nRetVal = ProcessRecord(FALSE);
				XN_IS_STATUS_OK(nRetVal);
			}

			/*Now, for each node, go to the position of the last encountered data record, and process that record
			  (including its payload).*/
			/*TODO: Optimization: remember each node's last data pos, and later, see if it changes. Only process data
			  frames of nodes whose last data pos actually changed.*/
			nRetVal = ProcessEachNodeLastData(nNodeID);
			XN_IS_STATUS_OK(nRetVal);
		}
	}

	return XN_STATUS_OK;
}