当前位置: 首页>>代码示例>>C++>>正文


C++ wxInputStream::IsOk方法代码示例

本文整理汇总了C++中wxInputStream::IsOk方法的典型用法代码示例。如果您正苦于以下问题:C++ wxInputStream::IsOk方法的具体用法?C++ wxInputStream::IsOk怎么用?C++ wxInputStream::IsOk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxInputStream的用法示例。


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

示例1: Read

bool IACFile::Read(wxInputStream &stream) {
    bool isok = false;  // true if minimum one token was read from file
    Invalidate();
    wxString token;
    m_tokensI = 0;
    if (stream.IsOk()) {
        for (;;) {
            token = ReadToken(stream);
            if (!token.IsEmpty()) {
                m_tokens.Add(token);
                m_tokensI++;
                isok = true;
            } else {
                break;
            }
        }
    }
    m_tokensI = 0;

    //    for (std::vector<size_t>::iterator it = m_newlineTokens.begin(); it != m_newlineTokens.end(); ++it)
    //    {
    //        wxMessageBox( wxString::Format( _T("ID: %i :"), *it ) + m_tokens[*it] );
    //    }

    if (isok) {
        // decode tokens if some were found
        isok = Decode();
    }
    m_isok = isok;
    return isok;
}
开发者ID:rgleason,项目名称:iacfleet_pi,代码行数:31,代码来源:iacfile.cpp

示例2: Put

bool wxCurlHTTP::Put(wxInputStream& buffer, const wxString& szRemoteFile /*= wxEmptyString*/)
{
    curl_off_t iSize = 0;

    if(m_pCURL && buffer.IsOk())
    {
        SetCurlHandleToDefaults(szRemoteFile);

        iSize = buffer.GetSize();

        if(iSize == (~(size_t)0))	// wxCurlHTTP does not know how to upload unknown length streams.
            return false;

        SetOpt(CURLOPT_UPLOAD, TRUE);
        SetOpt(CURLOPT_PUT, TRUE);
        SetStreamReadFunction(buffer);
        SetOpt(CURLOPT_INFILESIZE_LARGE, (curl_off_t)iSize);
        SetStringWriteFunction(m_szResponseBody);

        if(Perform())
        {
            return IsResponseOk();
        }
    }

    return false;
}
开发者ID:tvo,项目名称:springlobby,代码行数:27,代码来源:http.cpp

示例3: if

FbImportBook::FbImportBook(FbImportThread & owner, wxInputStream & in, const wxString & filename)
	: m_parser(NULL)
	, m_database(*owner.GetDatabase())
	, m_filename(owner.GetRelative(filename))
	, m_filepath(owner.GetAbsolute(filename))
	, m_filetype(Ext(m_filename))
	, m_message(filename)
	, m_filesize(in.GetLength())
	, m_archive(0)
	, m_ok(false)
{
	wxLogMessage(_("Import file %s"), m_filename.c_str());
	m_ok = in.IsOk();
	if (!m_ok) return;

	if (m_filetype == wxT("fb2")) {
		m_parser = new FbImportReaderFB2(in, true);
		m_md5sum = m_parser->GetMd5();
	} else if (m_filetype == wxT("epub")) {
		m_md5sum = CalcMd5(in);
		in.SeekI(0);
		wxString rootfile = FbRootReaderEPUB(in).GetRoot();
		in.SeekI(0);
		m_parser = new FbDataReaderEPUB(in, rootfile);
	} else {
		m_md5sum = CalcMd5(in);
	}
}
开发者ID:EvgeniiFrolov,项目名称:myrulib,代码行数:28,代码来源:FbImportReader.cpp

示例4: Put

bool wxCurlFTP::Put(wxInputStream& buffer, const wxString& szRemoteFile /*= wxEmptyString*/)
{
	curl_off_t iSize = 0;

	if(m_pCURL && buffer.IsOk())
	{
		SetCurlHandleToDefaults(szRemoteFile);

		iSize = buffer.GetSize();

		if(iSize == (~(ssize_t)0))
			return false;

		SetOpt(CURLOPT_UPLOAD, TRUE);
		SetStreamReadFunction(buffer);
		SetOpt(CURLOPT_INFILESIZE_LARGE, iSize);

		if(Perform())
		{
			return ((m_iResponseCode > 199) && (m_iResponseCode < 300));
		}
	}

	return false;
}
开发者ID:KastB,项目名称:OpenCPN,代码行数:25,代码来源:ftp.cpp

示例5: ReadToken

wxString IACFile::ReadToken(wxInputStream &file) {
    // 0 = read chars until digit
    // 1 = read digits until no digit
    // 2 = token found
    wxString token = wxEmptyString;

    int mode = 0;

    while (file.IsOk() && mode != 2) {
        int c = file.GetC();

        if (c != wxEOF && c <= 128) {
            if (c == '\n' && m_tokensI > 0) {
                m_newlineTokens.push_back(m_tokensI + 1);
            }
            m_RawData.Append((char)c);
            switch (mode) {
                case 0:
                    if (isdigit(c)) {
                        token.Append((char)c);
                        mode = 1;
                    }
                    break;
                case 1:
                    if (isdigit(c) || c == '/') {
                        token.Append((char)c);
                    } else {
                        if (token.Len() == 5) {
                            // token found!!
                            mode = 2;
                        } else {
                            token.Empty();
                        }
                    }
                    break;
                    /* this is dead code
                                case 2:
                                    mode = 0;
                                    break;
                    */
            }  // case
        }
    }  // while
    if (mode != 2) {
        token.Empty();
    }

    return token;
}
开发者ID:rgleason,项目名称:iacfleet_pi,代码行数:49,代码来源:iacfile.cpp

示例6: DeserializeFromXml

bool udSettings::DeserializeFromXml(wxInputStream& instream)
{
	if( instream.IsOk() )
	{
		if( !wxXmlSerializer::DeserializeFromXml( instream ) )
		{
			RemoveAll();
			this->CreateCategories();
		}
		else
			return true;
	}
	else
		this->CreateCategories();
		
	return false;
}
开发者ID:LETARTARE,项目名称:CodeDesigner,代码行数:17,代码来源:SettingsBase.cpp

示例7: buff_is

LifeReader::LifeReader(wxInputStream& is)
{
    wxBufferedInputStream buff_is(is);
    wxTextInputStream     text_is(buff_is);
    wxString              line, rest;

    // check stream
    m_ok = is.IsOk();
    LIFE_CHECKVAL(_("Couldn't read any data"));

    // read signature
    m_ok = text_is.ReadLine().Contains(wxT("#Life 1.05"));
    LIFE_CHECKVAL(_("Error reading signature. Not a Life pattern?"));

    // read description
    m_description = wxEmptyString;
    line = text_is.ReadLine();
    while (buff_is.IsOk() && line.StartsWith(wxT("#D"), &rest))
    {
        m_description += rest.Trim(false);
        m_description += wxT("\n");
        line = text_is.ReadLine();
    }

    m_ok = buff_is.IsOk();
    LIFE_CHECKVAL(_("Unexpected EOF while reading description"));

    // read rules
    m_ok = line.StartsWith(wxT("#N"));
    LIFE_CHECKVAL(_("Sorry, non-conway rules not supported yet"));

    // read shape
    while (buff_is.IsOk())
    {
        line = ( text_is.ReadLine() ).Trim();

        if (!line.empty())
        {
            if (line.StartsWith(wxT("#P "), &rest))
                m_shape.Add(rest);
            else
                m_shape.Add(line);
        }
    }
}
开发者ID:01org,项目名称:irk_host_linux,代码行数:45,代码来源:reader.cpp

示例8: CreateFileStream

/**
 * Creates a Stream pointing to a virtual file in
 * the current archive
 */
bool wxChmInputStream::CreateFileStream(const wxString& pattern)
{
    wxFileInputStream * fin;
    wxString tmpfile = wxFileName::CreateTempFileName(wxT("chmstrm"));

    if ( tmpfile.empty() )
    {
        wxLogError(_("Could not create temporary file '%s'"), tmpfile.c_str());
        return false;
    }

    // try to extract the file
    if ( m_chm->Extract(pattern, tmpfile) <= 0 )
    {
        wxLogError(_("Extraction of '%s' into '%s' failed."),
                   pattern.c_str(), tmpfile.c_str());
        if ( wxFileExists(tmpfile) )
            wxRemoveFile(tmpfile);
        return false;
    }
    else
    {
        // Open a filestream to extracted file
        fin = new wxFileInputStream(tmpfile);
        if (!fin->IsOk())
            return false;

        m_size = fin->GetSize();
        m_content = (char *) malloc(m_size+1);
        fin->Read(m_content, m_size);
        m_content[m_size]='\0';

        wxRemoveFile(tmpfile);

        delete fin;

        m_contentStream = new wxMemoryInputStream (m_content, m_size);

        return m_contentStream->IsOk();
    }
}
开发者ID:BloodRedd,项目名称:gamekit,代码行数:45,代码来源:chm.cpp

示例9: GetToken

bool GetToken(wxInputStream& input, wxString& result, unsigned int& lineNumber)
{

    result.Empty();

    SkipWhitespace(input, lineNumber);

    // Reached the end of the file.
    if (input.Eof())
    {
        return false;
    }

    char c = input.GetC();

    if (c == '\"')
    {

        // Quoted string, search for the end quote.

        do
        {
            result += c;
            c = input.GetC();
        }
        while (input.IsOk() && c != '\"');

        result += c;
        return true;

    }

    char n = input.Peek();

    if (IsDigit(c) || (c == '.' && IsDigit(n)) || (c == '-' && IsDigit(n)))
    {

        bool hasDecimal = false;

        while (!IsSpace(c))
        {

            result.Append(c);

            if (input.Eof())
            {
                return true;
            }

            c = input.Peek();

            if (!IsDigit(c) && c != '.')
            {
                return true;
            }

            input.GetC();

            if (c == '\n')
            {
                ++lineNumber;
                return true;
            }

        }

    }
    else
    {

        if (IsSymbol(c))
        {
            result = c;
            return true;
        }

        while (!IsSpace(c) && !input.Eof())
        {

            result.Append(c);

            if (IsSymbol(input.Peek()))
            {
                break;
            }

            c = input.GetC();

            if (c == '\n')
            {
                ++lineNumber;
                return true;
            }

        }

    }

    return true;

//.........这里部分代码省略.........
开发者ID:AlexHayton,项目名称:decoda,代码行数:101,代码来源:Tokenizer.cpp

示例10: IsOk

 bool IsOk() const
     { if (m_pStream == NULL) return FALSE; return m_pStream->IsOk(); }
开发者ID:rndstr,项目名称:SuperHud-Editor,代码行数:2,代码来源:download.cpp

示例11: ParseFileSymbols

void SymbolParserThread::ParseFileSymbols(wxInputStream& input, std::vector<Symbol*>& symbols)
{

    if (!input.IsOk())
    {
        return;
    }

    wxString token;

    unsigned int lineNumber = 1;

    while (GetToken(input, token, lineNumber))
    {
        if (token == "function")
        {

            unsigned int defLineNumber = lineNumber;

            // Lua functions can have these forms:
            //    function (...)
            //    function Name (...)
            //    function Module.Function (...)
            //    function Class:Method (...)

            wxString t1;
            if (!GetToken(input, t1, lineNumber)) break;

            if (t1 == "(")
            {
                // The form function (...) which doesn't have a name. If we
                // were being really clever we could check to see what is being
                // done with this value, but we're not.
                continue;
            }

            wxString t2;
            
            if (!GetToken(input, t2, lineNumber)) break;

            if (t2 == "(")
            {
                // The form function Name (...).
                symbols.push_back(new Symbol("", t1, defLineNumber));
            }
            else
            {
                
                wxString t3;
                if (!GetToken(input, t3, lineNumber)) break;

                if (t2 == "." || t2 == ":")
                {
                    symbols.push_back(new Symbol(t1, t3, defLineNumber));
                }

            }


        }
    }

}
开发者ID:FishingCactus,项目名称:decoda,代码行数:63,代码来源:SymbolParserThread.cpp

示例12: Load

bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type)
{
    UnRef();

    char anim_type[12];
    switch (type)
    {
    case wxANIMATION_TYPE_GIF:
        strcpy(anim_type, "gif");
        break;

    case wxANIMATION_TYPE_ANI:
        strcpy(anim_type, "ani");
        break;

    default:
        anim_type[0] = '\0';
        break;
    }

    // create a GdkPixbufLoader
    GError *error = NULL;
    GdkPixbufLoader *loader;
    if (type != wxANIMATION_TYPE_INVALID && type != wxANIMATION_TYPE_ANY)
        loader = gdk_pixbuf_loader_new_with_type(anim_type, &error);
    else
        loader = gdk_pixbuf_loader_new();

    if (!loader)
    {
        wxLogDebug(wxT("Could not create the loader for '%s' animation type"), anim_type);
        return false;
    }

    // connect to loader signals
    g_signal_connect(loader, "area-updated", G_CALLBACK(gdk_pixbuf_area_updated), this);

    guchar buf[2048];
    while (stream.IsOk())
    {
        // read a chunk of data
        stream.Read(buf, sizeof(buf));

        // fetch all data into the loader
        if (!gdk_pixbuf_loader_write(loader, buf, stream.LastRead(), &error))
        {
            gdk_pixbuf_loader_close(loader, &error);
            wxLogDebug(wxT("Could not write to the loader"));
            return false;
        }
    }

    // load complete
    if (!gdk_pixbuf_loader_close(loader, &error))
    {
        wxLogDebug(wxT("Could not close the loader"));
        return false;
    }

    // wait until we get the last area_updated signal
    return true;
}
开发者ID:Bluehorn,项目名称:wxPython,代码行数:62,代码来源:animate.cpp

示例13: Load

bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type)
{
    UnRef();

    char anim_type[12];
    switch (type)
    {
    case wxANIMATION_TYPE_GIF:
        strcpy(anim_type, "gif");
        break;

    case wxANIMATION_TYPE_ANI:
        strcpy(anim_type, "ani");
        break;

    default:
        anim_type[0] = '\0';
        break;
    }

    // create a GdkPixbufLoader
    GError *error = NULL;
    GdkPixbufLoader *loader;
    if (type != wxANIMATION_TYPE_INVALID && type != wxANIMATION_TYPE_ANY)
        loader = gdk_pixbuf_loader_new_with_type(anim_type, &error);
    else
        loader = gdk_pixbuf_loader_new();

    if (!loader ||
        error != NULL)  // even if the loader was allocated, an error could have happened
    {
        wxLogDebug(wxT("Could not create the loader for '%s' animation type: %s"),
                   anim_type, error->message);
        return false;
    }

    // connect to loader signals
    g_signal_connect(loader, "area-updated", G_CALLBACK(gdk_pixbuf_area_updated), this);

    guchar buf[2048];
    bool data_written = false;
    while (stream.IsOk())
    {
        // read a chunk of data
        if (!stream.Read(buf, sizeof(buf)) &&
            stream.GetLastError() != wxSTREAM_EOF)   // EOF is OK for now
        {
            // gdk_pixbuf_loader_close wants the GError == NULL
            gdk_pixbuf_loader_close(loader, NULL);
            return false;
        }

        // fetch all data into the loader
        if (!gdk_pixbuf_loader_write(loader, buf, stream.LastRead(), &error))
        {
            wxLogDebug(wxT("Could not write to the loader: %s"), error->message);

            // gdk_pixbuf_loader_close wants the GError == NULL
            gdk_pixbuf_loader_close(loader, NULL);
            return false;
        }

        data_written = true;
    }

    if (!data_written)
    {
        wxLogDebug("Could not read data from the stream...");
        return false;
    }

    // load complete: gdk_pixbuf_loader_close will now check if the data we
    // wrote inside the pixbuf loader does make sense and will give an error
    // if it doesn't (because of a truncated file, corrupted data or whatelse)
    if (!gdk_pixbuf_loader_close(loader, &error))
    {
        wxLogDebug(wxT("Could not close the loader: %s"), error->message);
        return false;
    }

    // wait until we get the last area_updated signal
    return data_written;
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:83,代码来源:animate.cpp

示例14: calculate

/**
 * Calculates the checksums from the given stream.
 *
 * @param  in         Input stream from which the data will be extracted to
 *                    compute the checksum. The data are extracted until the end
 *                    of the stream is reached.
 * @param  checksums  Array of checksums to calculate.
 * @param  sumValues  The calculated values of the checksums from the input
 *                    stream. The array is erased first before adding results.
 *                    On success <CODE>ArrayChecksum.GetCount() == sumValues.GetCount()</CODE>,
 *                    on failure, <CODE>sumValues</CODE> should be empty.
 * @return <UL>
 *           <LI><CODE>Ok</CODE> if the checksum has been successfully calculated.</Li>
 *           <LI><CODE>ReadError</CODE> if a read error has occured.</LI>
 *           <LI><CODE>Canceled</CODE> if the user has canceled the calculation.</LI>
 *         </UL>
 */
ChecksumCalculator::State ChecksumCalculator::calculate(wxInputStream& in,
                                                 const ArrayChecksum& checksums,
                                                       wxArrayString& sumValues)
{
  // Check if the input stream is valid.
  if (!in.IsOk())
    return ReadError;
  
  // Check if at least a checksum instance is OK.
  bool aInstanceOK = false;
  size_t i = 0;
  size_t s = checksums.GetCount();
  while (!aInstanceOK && i < s)
    if (checksums[i] != NULL)
      aInstanceOK = true;
    else
      i++;
  if (!aInstanceOK)
    return ReadError;
  
  // Initializes the buffer.
  const size_t bufSize = getBufferSize();
  wxByte* buff = new wxByte[bufSize];

  // Calculating the checksum.
  ChecksumProgress* p = getChecksumProgress();
  bool canceled = false;
  size_t read;
  wxStreamError lastError = wxSTREAM_NO_ERROR;
  s = checksums.GetCount();
  for (i = 0; i < s; i++)
    if (checksums[i] != NULL)
      checksums[i]->reset();
  while (!canceled && !in.Eof() && lastError == wxSTREAM_NO_ERROR)
  {
    in.Read(buff, bufSize);
    read = in.LastRead();
    if (read > 0 && read <= bufSize)
    {
      for (i = 0; i < s; i++)
        if (checksums[i] != NULL)
          checksums[i]->update(buff, read);
      if (p != NULL)
        p->update(read, canceled);
    }
    lastError = in.GetLastError();
  }

  // Cleans-up the memory
  delete[] buff;
  
  if (canceled)
    return CanceledByUser;
  
  if (lastError != wxSTREAM_NO_ERROR && lastError != wxSTREAM_EOF)
    return ReadError;
    
  sumValues.Empty();
  for (i = 0; i < s; i++)
    if (checksums[i] != NULL)
      sumValues.Add(checksums[i]->getValue());
    else
      sumValues.Add(wxEmptyString);

  return Ok;
}
开发者ID:gullinbursti,项目名称:as3gullinburstilibs,代码行数:83,代码来源:checksumutil.cpp

示例15: ParseFileSymbols

void SymbolParserThread::ParseFileSymbols(wxInputStream& input, std::vector<Symbol*>& symbols)
{

    if (!input.IsOk())
    {
        return;
    }

    wxString token;

    unsigned int lineNumber = 1;

    Symbol *return_symbol = nullptr;

    wxStack<Symbol *> symStack;
    symStack.push(nullptr);

    std::vector<Token> tokens;
    while (GetToken(input, token, lineNumber))
    {
      tokens.emplace_back(token, lineNumber);
    }

    for (unsigned current_token = 0; current_token < tokens.size(); ++current_token)
    {
      token = tokens[current_token].token;
      lineNumber = tokens[current_token].lineNumber;

      if (token == "function")
      {
        unsigned int defLineNumber = lineNumber;
        Symbol *function = nullptr;

        // Lua functions can have these forms:
        //    function (...)
        //    function Name (...)
        //    function Module.Function (...)
        //    function Class:Method (...)

        wxString t1;
        if (!GetNextToken(tokens, t1, lineNumber, current_token)) break;

        if (t1 == "(")
        {
          // The form function (...) which doesn't have a name. If we
          // were being really clever we could check to see what is being
          // done with this value, but we're not.
          continue;
        }

        wxString t2;

        if (!GetNextToken(tokens, t2, lineNumber, current_token)) break;

        if (t2 == "(")
        {
          function = new Symbol(symStack.top(), t1, defLineNumber);

          if (return_symbol)
          {
            function->typeSymbol = return_symbol;
            return_symbol = nullptr;
          }

          // The form function Name (...).
          symbols.push_back(function);
        }
        else
        {

          wxString t3;
          if (!GetNextToken(tokens, t3, lineNumber, current_token)) break;

          if (t2 == "." || t2 == ":")
          {
            Symbol *module = GetSymbol(t1, symbols);
            if (module == nullptr)
            {
              module = new Symbol(symStack.top(), t1, defLineNumber, SymbolType::Module);
              symbols.push_back(module);
            }

            function = new Symbol(module, t3, defLineNumber);
            if (return_symbol)
            {
              function->typeSymbol = return_symbol;
              return_symbol = nullptr;
            }

            symbols.push_back(function);
          }

        }


        if (function)
          symStack.push(function);

      }
      else if (token == "decodadef")
//.........这里部分代码省略.........
开发者ID:gmax79,项目名称:decoda,代码行数:101,代码来源:SymbolParserThread.cpp


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