Beispiel #1
0
void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) {
  m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
  if (IsEOF()) {
    return;
  }
  int32_t i = 0, iLen = str.GetLength();
  do {
    while (m_dwIndex < m_dwBufferSize) {
      if (str.GetAt(i) != m_pBuffer[m_dwIndex++]) {
        i = 0;
      } else {
        i++;
        if (i == iLen) {
          break;
        }
      }
    }
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (i == iLen) {
      return;
    }
    if (m_dwIndex < m_dwBufferSize || IsEOF()) {
      break;
    }
  } while (ReadNextBlock());
  while (!m_pDataAcc->IsEOF()) {
    ReadNextBlock();
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwBufferSize;
  }
  m_dwIndex = m_dwBufferSize;
}
Beispiel #2
0
bool Tokenizer::SkipToEOL(bool nestBraces, bool skippingComment)
{
    // skip everything until we find EOL
    while (1)
    {
        while (NotEOF() && CurrentChar() != '\n')
        {
            if (CurrentChar() == '/' && NextChar() == '*')
            {
                SkipComment(false); // don't skip whitespace after the comment
                if (skippingComment && CurrentChar() == '\n')
                {
                    continue; // early exit from the loop
                }
            }
            if (nestBraces && CurrentChar() == _T('{'))
                ++m_NestLevel;
            else if (nestBraces && CurrentChar() == _T('}'))
                --m_NestLevel;
            MoveToNextChar();
        }
        wxChar last = PreviousChar();
        // if DOS line endings, we 've hit \r and we skip to \n...
        if (last == '\r')
            last = m_Buffer.GetChar(m_TokenIndex - 2);
        if (IsEOF() || last != '\\')
            break;
        else
            MoveToNextChar();
    }
    if (IsEOF())
        return false;
    return true;
}
Beispiel #3
0
void CXML_Parser::GetName(CFX_ByteString& space, CFX_ByteString& name) {
  m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
  if (IsEOF()) {
    return;
  }
  CFX_ByteTextBuf buf;
  uint8_t ch;
  do {
    while (m_dwIndex < m_dwBufferSize) {
      ch = m_pBuffer[m_dwIndex];
      if (ch == ':') {
        space = buf.AsStringC();
        buf.Clear();
      } else if (g_FXCRT_XML_IsNameChar(ch)) {
        buf.AppendChar(ch);
      } else {
        break;
      }
      m_dwIndex++;
    }
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (m_dwIndex < m_dwBufferSize || IsEOF()) {
      break;
    }
  } while (ReadNextBlock());
  name = buf.AsStringC();
}
Beispiel #4
0
bool TextCutter::SkipWhiteSpace()
{
    if (IsEOF())
        return false;
    while (!IsEOF() && isspace(CurrentChar()))
        MoveToNextChar();
    return true;
}
Beispiel #5
0
void CollateRecordset::MoveNext()
{
    if (!IsEOF())
    {
	++m_index;
	if (m_index == m_items.size() && !IsEOF())
	    GetSome();
    }
}
Beispiel #6
0
void SearchRecordset::MoveNext()
{
    if (!IsEOF())
    {
	++m_index;
	if (m_index == m_items.size() && !IsEOF())
	    GetSome();
	SelectThisItem();
    }
}
Beispiel #7
0
BOOL CSourceODBC::stdFillTable1(CString field1, CString& strValue1, CString field2, long& lngValue2)
{
    if ( IsEOF() ) return FALSE;

    strValue1 = m_database.GetColomn(CString(field1))->GetValueAsString();
    lngValue2 = m_database.GetColomn(CString(field2))->GetValueAsLong();
    MoveNext();
    if ( IsEOF() ) return FALSE;
    return TRUE;
}
void CSessions::clearRecords()
{
	if (!IsBOF() || !IsEOF())
	{
		while (!IsEOF())
		{
			Delete();
			MoveNext();
		}
	}

}
Beispiel #9
0
void CXML_Parser::GetTagName(CFX_ByteString& space,
                             CFX_ByteString& name,
                             bool& bEndTag,
                             bool bStartTag) {
  m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
  if (IsEOF()) {
    return;
  }
  bEndTag = false;
  uint8_t ch;
  int32_t iState = bStartTag ? 1 : 0;
  do {
    while (m_dwIndex < m_dwBufferSize) {
      ch = m_pBuffer[m_dwIndex];
      switch (iState) {
        case 0:
          m_dwIndex++;
          if (ch != '<') {
            break;
          }
          iState = 1;
          break;
        case 1:
          if (ch == '?') {
            m_dwIndex++;
            SkipLiterals("?>");
            iState = 0;
            break;
          } else if (ch == '!') {
            m_dwIndex++;
            SkipLiterals("-->");
            iState = 0;
            break;
          }
          if (ch == '/') {
            m_dwIndex++;
            GetName(space, name);
            bEndTag = true;
          } else {
            GetName(space, name);
            bEndTag = false;
          }
          return;
      }
    }
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (m_dwIndex < m_dwBufferSize || IsEOF()) {
      break;
    }
  } while (ReadNextBlock());
}
Beispiel #10
0
void TextCutter::SkipUnwanted()
{
    if (IsEOF())
        return;
	while (CurrentChar() == '#' ||
           CurrentChar() == '!' ||
           ((CurrentChar() == 'c' || CurrentChar() == 'C' || CurrentChar() == '*') && m_CurColumn == 1 && m_CurSourceForm == fsfFixed))
	{
        SkipToEOL();
        SkipWhiteSpace();
        if (IsEOF())
            return;
	}
}
Beispiel #11
0
void TextCutter::GetChunk(wxString& chunk, bool& isWord)
{
    isWord = false;
    chunk = wxEmptyString;
    if (IsEOF())
        return;

    unsigned int start = m_CurIdx;
    if (isalpha(CurrentChar()) || CurrentChar() == '_')
    {
        while (!IsEOF() &&
               (isalnum(CurrentChar()) || CurrentChar() == '_'))
            MoveToNextChar();
        chunk = m_Text.Mid(start, m_CurIdx - start);
        isWord = true;
    }
    else
    {
        SkipWhiteSpace();
        SkipUnwanted();
        if (start != m_CurIdx)
        {
            chunk = m_Text.Mid(start, m_CurIdx - start);
            return;
        }

        if (isdigit(CurrentChar()))
        {
            // numbers
            while (!IsEOF() && CharInString(CurrentChar(), "0123456789.abcdefABCDEFXxLl"))
                MoveToNextChar();

        }
        else if (CurrentChar() == '"' ||
                CurrentChar() == '\'')
        {
            // string, char, etc.
            wxChar match = CurrentChar();
            MoveToNextChar();  // skip starting ' or "
            SkipToChar(match);
            MoveToNextChar(); // skip ending ' or "
        }
        else
        {
            MoveToNextChar();
        }
        chunk = m_Text.Mid(start, m_CurIdx - start);
    }
    return;
}
Beispiel #12
0
void CXML_Parser::GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOOL &bEndTag, FX_BOOL bStartTag)
{
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (IsEOF()) {
        return;
    }
    bEndTag = FALSE;
    FX_BYTE ch;
    FX_INT32 iState = bStartTag ? 1 : 0;
    do {
        while (m_dwIndex < m_dwBufferSize) {
            ch = m_pBuffer[m_dwIndex];
            switch (iState) {
                case 0:
                    m_dwIndex ++;
                    if (ch != '<') {
                        break;
                    }
                    iState = 1;
                    break;
                case 1:
                    if (ch == '?') {
                        m_dwIndex ++;
                        SkipLiterals(FX_BSTRC("?>"));
                        iState = 0;
                        break;
                    } else if (ch == '!') {
                        m_dwIndex ++;
                        SkipLiterals(FX_BSTRC("-->"));
                        iState = 0;
                        break;
                    }
                    if (ch == '/') {
                        m_dwIndex ++;
                        GetName(space, name);
                        bEndTag = TRUE;
                    } else {
                        GetName(space, name);
                        bEndTag = FALSE;
                    }
                    return;
            }
        }
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
        if (m_dwIndex < m_dwBufferSize || IsEOF()) {
            break;
        }
    } while (ReadNextBlock());
}
   double
   PGRecordset::GetDoubleValue(const AnsiString &FieldName) const
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Returns the value of a string in the current row in the recordset.
   //---------------------------------------------------------------------------()
   {
      if (IsEOF())
      {
         ReportEOFError_(FieldName);
         return 0;
      }

      try
      {
         int iColIdx = GetColumnIndex_(FieldName);
         char *pValue = PQgetvalue(result_, cur_row_num_, iColIdx);
         double dbVal = pValue ? atof(pValue) : 0;

         return dbVal;
      }
      catch (...)
      {
         ErrorManager::Instance()->ReportError(ErrorManager::Medium, 5091, "PGRecordset::GetDoubleValue", "An unknown error occurred while reading value from recordset: " + FieldName);
         throw;
      }
   }
Beispiel #14
0
void SearchRecordset::SelectThisItem()
{
    if (IsEOF())
	return;

    mediadb::didl::MetadataList::const_iterator ci = m_items.begin();

    for (unsigned int i=0; i<m_index; ++i)
	++ci;

    std::string objectid;
    for (mediadb::didl::Metadata::const_iterator i = ci->begin();
	 i != ci->end();
	 ++i)
	if (i->tag == "id")
	{
	    objectid = i->content;
	    break;
	}

    m_freers = db::FreeRecordset::Create();
    mediadb::didl::ToRecord(*ci, m_freers);
    m_id = m_parent->IdForObjectId(objectid);
    m_got_what = GOT_BASIC;
}
Beispiel #15
0
BOOL CSqlite3Recordset::GetField(short iIndex, LPTSTR pData, UINT cchMax)
{
   _ASSERTE(IsOpen());
   _ASSERTE(iIndex>=0 && iIndex<m_nCols);
   if( IsEOF() ) return FALSE;
   if( iIndex < 0 || iIndex >= m_nCols ) return FALSE;
   if( m_lType == DB_OPEN_TYPE_FORWARD_ONLY ) {
#if !defined(UNICODE)
      USES_CONVERSION;
      _tcsncpy(pData, A2T( (char*)::sqlite3_column_text(m_pVm, iIndex) ), cchMax);
#else  // UNICODE
      _tcsncpy(pData, (WCHAR*) ::sqlite3_column_text16(m_pVm, iIndex), cchMax);
#endif // UNICODE
   }
   else {
      LPSTR pstr = m_ppSnapshot[ ((m_iPos + 1) * m_nCols) + iIndex ];
      if( pstr == NULL ) {
         _tcscpy(pData, _T(""));
      }
      else {
         USES_CONVERSION;
         LPCSTR pstr = m_ppSnapshot[ ((m_iPos + 1) * m_nCols) + iIndex ];
         _tcsncpy(pData, A2CT(pstr), cchMax);
      }
   }
   return TRUE;
}
wchar_t EasyUnicodeFileLE::readWchar( )//读取一个宽字符
{
	if( !IsReadMode ) return L'';//输出模式不允许读入
	if( IsEOF( ) ) return L'';//如果已经在文件尾了,就不读了

	wchar_t Temp2[ 2 ];
	wchar_t tempWC[ 2 ];
	try {
		F.read( (char *)tempWC, 2 );
		tempWC[ 1 ] = L'\0';

		if( tempWC[ 0 ] == L'\x000D' ) {
			F.read( (char *)Temp2, 2 );
			Temp2[ 1 ] = L'\0';
			if( Temp2[ 0 ] == L'\x000A' ) return L'\n';
			else {
				SetPointer( -1, ios_base::cur );
				return tempWC[ 0 ];
			}
		}
		else return tempWC[ 0 ];
	}
	catch( ... ) {
		cout << "ERROR_EUFLE008 - Unknown error." << endl;
		system( "PAUSE" );
		return L'';
	}
	return tempWC[ 0 ];
}
   bool 
   PGRecordset::GetIsNull(const AnsiString &FieldName) const
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Returns true if the column contains NULL
   //---------------------------------------------------------------------------()
   {
      if (IsEOF())
      {
         ReportEOFError_(FieldName);
         return false;
      }

      try
      {
         int iColIdx = GetColumnIndex_(FieldName);
         bool isNull = PQgetisnull(result_, cur_row_num_, iColIdx) == 1;

         return isNull;
      }
      catch (...)
      {
         ErrorManager::Instance()->ReportError(ErrorManager::High, 5301, "PGRecordset::GetIsNull", "An error occured while checking for null.");
         throw;
      }
   }
Beispiel #18
0
void CXML_Parser::SkipWhiteSpaces() {
  m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
  if (IsEOF()) {
    return;
  }
  do {
    while (m_dwIndex < m_dwBufferSize &&
           g_FXCRT_XML_IsWhiteSpace(m_pBuffer[m_dwIndex])) {
      m_dwIndex++;
    }
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (m_dwIndex < m_dwBufferSize || IsEOF()) {
      break;
    }
  } while (ReadNextBlock());
}
Beispiel #19
0
      /// <summary>Reads the next line, if any</summary>
      /// <param name="line">The line.</param>
      /// <returns>True if read, false if EOF</returns>
      /// <exception cref="Logic::InvalidOperationException">Stream has been closed (reader has been move-copied)</exception>
      /// <exception cref="Logic::IOException">An I/O error occurred</exception>
      bool  StringReader::ReadLine(wstring&  line)
      {
         DWORD start = Position,    // Start of line
               end   = Length;      // End of characters on line
         WCHAR ch;

         // EOF: Return false
         if (IsEOF())
         {
            line.clear();
            return false;
         }

         // Search for EOF/CRLF/CR
         while (ReadChar(ch))
         {
            // CR/LF/CRLF: Set of chars marker, 
            if (ch == '\r' || ch == '\n')
            {
               // Mark end-of-text
               end = Position-1;

               // Consume entire CRLF if present
               if (ch == '\r' && PeekChar(ch) && ch == '\n')
                  ReadChar(ch);

               // Position marker now at start of new line, end-of-char marker at last character
               break;
            }
         }

         // Return line text without CRLF
         line = wstring(Buffer.get() + start, Buffer.get() + end);
         return true;
      }
Beispiel #20
0
/*===========================================================================
 *
 * Class CSrFile Method - bool ReadLine (Buffer);
 *
 * Inputs a line of text from a text file.
 *
 *=========================================================================*/
bool CSrFile::ReadLine (CSString& Buffer) {
  byte    Value;
  size_t  Result;
  //SSCHAR  TempBuffer[256];
  //SSCHAR* pResult;

	/* Set some initial string size */
  Buffer.SetSizeEmpty(64);
  //Buffer.Empty();

  while (!IsEOF()) {
 
     		/* Attempt to input buffer */
    Result = fread(&Value, 1, 1, m_pFile);

    if (Result != 1) {
      if (HasError()) return AddSrSystemError("Failed to read byte from file!");
      return (true);
    }

    if (Value == '\n') {
      ++m_LineCount;
      return (true);
     }
    else {
      Buffer += Value;
     }
   }

  return (true);
}
Beispiel #21
0
      /// <summary>Reads the next character</summary>
      /// <param name="c">Next character</param>
      /// <returns>True if read, false if EOF</returns>
      /// <exception cref="Logic::InvalidOperationException">Stream has been closed (reader has been move-copied)</exception>
      /// <exception cref="Logic::IOException">An I/O error occurred</exception>
      bool  StringReader::ReadChar(WCHAR&  c)
      {
         // Ensure stream has not been moved
         if (Input == nullptr)
            throw InvalidOperationException(HERE, L"Underlying stream has been closed");

         // First Call: Read entire file 
         else if (Buffer == nullptr)
            Buffer = FileStream::ConvertFileBuffer(Input, Length);

         // EOF: Return false
         if (IsEOF())
         {
            c = NULL;
            return false;
         }

         // Increment line number 
         if (c == L'\n')
            LineNum++;

         // Set byte, advance position, return true
         c = Buffer.get()[Position++];
         return true;
      }
Beispiel #22
0
BOOL CSqlite3Recordset::MoveBottom()
{
   _ASSERTE(IsOpen());
   if( m_lType == DB_OPEN_TYPE_FORWARD_ONLY ) return _Error(1, 1, "Invalid recordset type");
   if( m_nRows == 0 ) return FALSE;
   m_iPos = m_nRows - 1;
   return IsEOF();
}
 bool Loop()
 {
    size_t row = 0;
    if (!(IsBOF() && IsEOF())) for (MoveFirst(); !IsEOF(); MoveNext(), row++)
    {
       //TRACE(_T("row %3d\n"), row);
       NewRecord();
       for (int i = 0; i < GetFieldCount(); i++)
       {
          COleVariant var;
    	   GetFieldValue(i, var);
          SaveField(i, var);
       }
       SaveRecord();
    }
    return true;
 }
Beispiel #24
0
bool Tokenizer::SkipUnwanted()
{
    while (SkipWhiteSpace() || SkipComment())
        ;

    wxChar c = CurrentChar();
    const unsigned int startIndex = m_TokenIndex;

    if (c == _T('#'))
    {
        const PreprocessorType type = GetPreprocessorType();
        if (type != ptOthers)
        {
            HandleConditionPreprocessor(type);
            c = CurrentChar();
        }
    }

    // skip [XXX][YYY]
    if (m_State & tsSkipSubScrip)
    {
        while (c == _T('[') )
        {
            SkipBlock('[');
            SkipWhiteSpace();
            if (IsEOF())
                return false;
            c = CurrentChar();
        }
    }

    // skip the following = or ?
    if (m_State & tsSkipEqual)
    {
        if (c == _T('='))
        {
            if (!SkipToOneOfChars(_T(",;}"), true, true, false))
                return false;
        }
    }
    else if (m_State & tsSkipQuestion)
    {
        if (c == _T('?'))
        {
            if (!SkipToOneOfChars(_T(";}"), false, true))
                return false;
        }
    }

    // skip the following white space and comments
    while (SkipWhiteSpace() || SkipComment())
        ;

    if (startIndex != m_TokenIndex && CurrentChar() == _T('#'))
        return SkipUnwanted();

    return NotEOF();
}
Beispiel #25
0
bool TextCutter::MoveToNextChar()
{
    if (IsEOF())
        return false;
	++m_CurIdx;
	++m_CurColumn;
    AdjustColumn();
    return true;
}
void EasyUnicodeFileLE::SetPointer( std::streamoff off, basic_istream< char, char_traits< char > >::pos_type PosType )
{
	/*
	参数说明:
		off :需要偏移的值
		PosType :搜索的起始位置
	枚举类型:
		enum seek_dir {beg, cur, end};
		每个枚举常量的含义:
		ios::beg :文件流的起始位置
		ios::cur :文件流的当前位置
		ios::end :文件流的结束位置
	*/

	//注意文件头
	if( IsEOF( ) ) F.clear( );

	if( (int)PosType == ios_base::beg && off >= 0 ) {
		F.seekg( 2 /*+ 2 * off*/, ios_base::beg );//FF FE
		for( int i = 0; i < off; i ++ ) readWchar( );
	}
	else if( (int)PosType == ios_base::cur ) {
		F.seekg( 0/*2 * off*/, ios_base::cur );
		if( off >= 0 ) for( int i = 0; i < off; i ++ ) readWchar( );
		else for( int i = 0; i < -off; i ++ ) {
			try {
				F.seekg( -4, ios_base::cur );
				if( readWchar( ) == L'\n' ) {
					F.seekg( -4, ios_base::cur );
					continue;
				}
			}
			catch( ... ) {
				cout << "ERROR_EUFLE010 - Unknown error." << endl;
				system( "PAUSE" );
			}
		}
	}
	else if( (int)PosType == ios_base::end && off <= 0 ) {
		F.seekg( 0/*2 * off*/, ios_base::end );
		for( int i = 0; i < -off; i ++ ) {
			try {
				F.seekg( -4, ios_base::cur );
			   	if( readWchar( ) == L'\n' ) {
					F.seekg( -4, ios_base::cur );
					continue;
				}
			}
			catch( ... ) {
				cout << "ERROR_EUFLE011 - Unknown error." << endl;
				system( "PAUSE" );
   			}
		}
	}
	else cout << "ERROR_EUFLE012 - Unsupport referring file mode." << endl;
	return;
}
Beispiel #27
0
bool Tokenizer::SkipWhiteSpace()
{
    // skip spaces, tabs, etc.
    while (CurrentChar() <= _T(' ') && MoveToNextChar()) // don't check EOF when MoveToNextChar already does, also replace isspace() which calls msvcrt.dll
        ;                                                // with a dirty hack:  CurrentChar() <= ' ' is "good enough" here
    if (IsEOF())
        return false;
    return true;
}
Beispiel #28
0
bool Tokenizer::SkipToOneOfChars(const wxChar* chars, bool supportNesting)
{
    // skip everything until we find any one of chars
    while (1)
    {
        while (NotEOF() && !CharInString(CurrentChar(), chars))
        {
            if (CurrentChar() == '"' || CurrentChar() == '\'')
            {
                // this is the case that match is inside a string!
                wxChar ch = CurrentChar();
                MoveToNextChar();
                SkipToChar(ch);
            }
            MoveToNextChar();

            // make sure we skip comments
            if (CurrentChar() == '/')
                SkipComment(); // this will decide if it is a comment

            // use 'while' here to cater for consecutive blocks to skip (e.g. sometemplate<foo>(bar)
            // must skip <foo> and immediately after (bar))
            // because if we don't, the next block won't be skipped ((bar) in the example) leading to weird
            // parsing results
            bool done = false;
            while (supportNesting && !done)
            {
                switch (CurrentChar())
                {
                    case '{': SkipBlock('{'); break;
                    case '(': SkipBlock('('); break;
                    case '[': SkipBlock('['); break;
                    case '<': // don't skip if << operator
                        if (NextChar() == '<')
                            MoveToNextChar(2); // skip it and also the next '<' or the next '<' leads to a SkipBlock('<');
                        else
                            SkipBlock('<');
                        break;
                    default: done = true; break;
                }
            }
        }
        if (PreviousChar() != '\\')
            break;
        else
        {
            // check for "\\"
            if (m_TokenIndex - 2 >= 0 && m_Buffer.GetChar(m_TokenIndex - 2) == '\\')
                break;
        }
        MoveToNextChar();
    }
    if (IsEOF())
        return false;
    return true;
}
Beispiel #29
0
void TextCutter::SkipToChar(const wxChar& ch)
{
	// skip everything until we find ch
	while (1)
	{
		while (!IsEOF() && CurrentChar() != ch && CurrentChar() != '\n')
			MoveToNextChar();
        break;
	}
}
Beispiel #30
0
void CXML_Parser::GetAttrValue(CFX_WideString &value)
{
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (IsEOF()) {
        return;
    }
    CFX_UTF8Decoder decoder;
    uint8_t mark = 0, ch = 0;
    do {
        while (m_dwIndex < m_dwBufferSize) {
            ch = m_pBuffer[m_dwIndex];
            if (mark == 0) {
                if (ch != '\'' && ch != '"') {
                    return;
                }
                mark = ch;
                m_dwIndex ++;
                ch = 0;
                continue;
            }
            m_dwIndex ++;
            if (ch == mark) {
                break;
            }
            if (ch == '&') {
                decoder.AppendChar(GetCharRef());
                if (IsEOF()) {
                    value = decoder.GetResult();
                    return;
                }
            } else {
                decoder.Input(ch);
            }
        }
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
        if (ch == mark || m_dwIndex < m_dwBufferSize || IsEOF()) {
            break;
        }
    } while (ReadNextBlock());
    value = decoder.GetResult();
}