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


C++ wxOutputStream::Write方法代码示例

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


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

示例1: OutputString

// write string to output:
inline static void OutputString(wxOutputStream& stream, const wxString& str,
                                wxMBConv *convMem = NULL,
                                wxMBConv *convFile = NULL)
{
    if (str.empty())
        return;

#if wxUSE_UNICODE
    wxUnusedVar(convMem);

    const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
    if ( !buf )
        return;
    stream.Write((const char*)buf, strlen((const char*)buf));
#else // !wxUSE_UNICODE
    if ( convFile && convMem )
    {
        wxString str2(str.wc_str(*convMem), *convFile);
        stream.Write(str2.mb_str(), str2.Len());
    }
    else // no conversions to do
    {
        stream.Write(str.mb_str(), str.Len());
    }
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
}
开发者ID:252525fb,项目名称:rpcs3,代码行数:27,代码来源:xml.cpp

示例2: fn

void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out,
                                                   const wxString& archiver)
{
    // for an external archiver the test data need to be written to
    // temp files
    TempDir tmpdir;

    // write the files
    TestEntries::iterator i;
    for (i = m_testEntries.begin(); i != m_testEntries.end(); ++i) {
        wxFileName fn(i->first, wxPATH_UNIX);
        TestEntry& entry = *i->second;

        if (fn.IsDir()) {
            fn.Mkdir(0777, wxPATH_MKDIR_FULL);
        } else {
            wxFileName::Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL);
            wxFFileOutputStream fileout(fn.GetFullPath());
            fileout.Write(entry.GetData(), entry.GetSize());
        }
    }

    for (i = m_testEntries.begin(); i != m_testEntries.end(); ++i) {
        wxFileName fn(i->first, wxPATH_UNIX);
        TestEntry& entry = *i->second;
        wxDateTime dt = entry.GetDateTime();
#ifdef __WXMSW__
        if (fn.IsDir())
            entry.SetDateTime(wxDateTime());
        else
#endif
            fn.SetTimes(NULL, &dt, NULL);
    }

    if ((m_options & PipeOut) == 0) {
        wxFileName fn(tmpdir.GetName());
        fn.SetExt(_T("arc"));
        wxString tmparc = fn.GetPath(wxPATH_GET_SEPARATOR) + fn.GetFullName();

        // call the archiver to create an archive file
        system(wxString::Format(archiver, tmparc.c_str()).mb_str());

        // then load the archive file
        {
            wxFFileInputStream in(tmparc);
            if (in.Ok())
                out.Write(in);
        }

        wxRemoveFile(tmparc);
    }
    else {
        // for the non-seekable test, have the archiver output to "-"
        // and read the archive via a pipe
        PFileInputStream in(wxString::Format(archiver, _T("-")));
        if (in.Ok())
            out.Write(in);
    }
}
开发者ID:project-renard-survey,项目名称:chandler,代码行数:59,代码来源:archivetest.cpp

示例3: CheckLastWrite

/* static */ bool IStateStore::WriteLine(wxOutputStream& output, const wxString& txt)
{
	wxInt32 len = txt.Len();
	output.Write(txt.c_str(), len );
	bool ret = CheckLastWrite(output, len);
	
	if (ret)
	{
		output.Write("\r", 1); 
	}
	
	return ret;
}
开发者ID:mauzerX,项目名称:universal-translators-tool,代码行数:13,代码来源:istatestore.cpp

示例4: SavePoints

Void CFxLine::SavePoints(wxOutputStream& stream)
{
	vPointIter Iter;
	wxPoint Point;

	for (Iter = _NodeVector.begin(); (Iter != _NodeVector.end()) && !(_NodeVector.empty()); Iter++)
	{
		(*Iter)->GetPoint(&Point);
		stream.Write((Char*)&(Point.x), sizeof(int));
		stream.Write((Char*)&(Point.y), sizeof(int));
        int sdwPointType = (*Iter)->GetType();
        stream.Write((Char*)&(sdwPointType), sizeof(int));
	}
	return;
}
开发者ID:toddyjiang,项目名称:ZX,代码行数:15,代码来源:FxLine.cpp

示例5: integers

/*!
 This function is called for every value objects of INT type.
 This function uses the \n snprintf function to get the US-ASCII
 representation of the integer and simply copy it to the output stream.
 Returns -1 on stream errors or ZERO if no errors.
*/
int
wxJSONWriter::WriteIntValue( wxOutputStream& os, const wxJSONValue& value )
{
    int r = 0;
    char buffer[32];        // need to store 64-bits integers (max 20 digits)
    size_t len;

    wxJSONRefData* data = value.GetRefData();
    wxASSERT( data );

#if defined( wxJSON_64BIT_INT )

        // this is for wxW 2.8 Unicode: in order to use the cross-platform
        // format specifier, we use the wxString's sprintf() function and then
        // convert to UTF-8 before writing to the stream
        wxString s;
        s.Printf( _T("%") wxLongLongFmtSpec _T("d"),
                                                data->m_value.m_valInt64 );
        wxCharBuffer cb = s.ToUTF8();
        const char* cbData = cb.data();
        len = strlen( cbData );
        wxASSERT( len < 32 );
        memcpy( buffer, cbData, len );
        buffer[len] = 0;
    
#else
    snprintf( buffer, 32, "%ld", data->m_value.m_valLong );
#endif
    len = strlen( buffer );
    os.Write( buffer, len );
    if ( os.GetLastError() != wxSTREAM_NO_ERROR )    {
        r = -1;
    }
    return r;
}
开发者ID:hihihippp,项目名称:kiku,代码行数:41,代码来源:jsonwriter.cpp

示例6: WriteOut

/** @brief Write the database to an output stream
 *
 * @param tokenDatabase The database to write
 * @param out Were to write the database to
 * @return true if the operation was successful, false otherwise
 *
 */
bool ClTokenDatabase::WriteOut( const ClTokenDatabase& tokenDatabase, wxOutputStream& out )
{
    int i;
    int cnt;
    out.Write("CbCc", 4); // Magic number
    WriteInt(out, 1); // Version number

    WriteInt(out, ClTokenPacketType_filenames);
    if (!ClFilenameDatabase::WriteOut(tokenDatabase.m_FileDB, out))
        return false;

    wxMutexLocker(tokenDatabase.m_Mutex);

    WriteInt(out, ClTokenPacketType_tokens);
    cnt = tokenDatabase.m_pTokens->GetCount();

    WriteInt(out, cnt);
    uint32_t written_count = 0;
    for (i = 0; i < cnt; ++i)
    {
        ClAbstractToken tok = tokenDatabase.m_pTokens->GetValue(i);
        if (!ClAbstractToken::WriteOut(tok, out))
            return false;
        written_count++;
    }
    CCLogger::Get()->DebugLog(F(_T("Wrote token database: %d tokens"), written_count));
    return true;
}
开发者ID:stahta01,项目名称:ClangLib,代码行数:35,代码来源:tokendatabase.cpp

示例7: called

/*!
 An invalid wxJSONValue is a value that was not initialized and it is
 an error. You should never write invalid values to JSON text because
 the output is not valid JSON text.
 Note that the NULL value is a legal JSON text and it is written:
 \code
  null
 \endcode

 This function writes a non-JSON text to the output stream:
 \code
  <invalid JSON value>
 \endcode
 In debug mode, the function always fails with an wxFAIL_MSG failure.
*/
int
wxJSONWriter::WriteInvalid( wxOutputStream& os )
{
    wxFAIL_MSG( _T("wxJSONWriter::WriteInvalid() cannot be called (not a valid JSON text"));
    int lastChar = 0;
    os.Write( "<invalid JSON value>", 9 );
    return lastChar;
}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:23,代码来源:jsonwriter.cpp

示例8:

/*!
 The function writes the \b null literal string to the output stream.
*/
int
wxJSONWriter::WriteNullValue( wxOutputStream& os )
{
    os.Write( "null", 4 );
    if ( os.GetLastError() != wxSTREAM_NO_ERROR )    {
        return -1;
    }
    return 0;
}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:12,代码来源:jsonwriter.cpp

示例9: wxLogTrace

//! Write the key of a key/value element to the output stream.
int
wxJSONWriter::WriteKey( wxOutputStream& os, const wxString& key )
{
    wxLogTrace( writerTraceMask, _T("(%s) key write=%s"),
                  __PRETTY_FUNCTION__, key.c_str() );

    int lastChar = WriteStringValue( os, key );
    os.Write( " : ", 3 );
    return lastChar;
}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:11,代码来源:jsonwriter.cpp

示例10: ansiCB

/*!
 This function is called for every value objects of DOUBLE type.
 This function uses the \n snprintf function to get the US-ASCII
 representation of the integer and simply copy it to the output stream.
 Returns -1 on stream errors or ZERO if no errors.

 Note that writing a double to a decimal ASCII representation could
 lay to unexpected results depending on the format string used in the
 conversion.
 See SetDoubleFmtString for details.
*/
int
wxJSONWriter::WriteDoubleValue( wxOutputStream& os, const wxJSONValue& value )
{
    int r = 0;

    wxJSONRefData* data = value.GetRefData();
    wxASSERT( data );

    char* writeBuff = 0;
    // the buffer that has to be written is either UTF-8 or ANSI c_str() depending
    // on the 'm_noUtf8' flag
    wxCharBuffer utf8CB = wxString::FromCDouble(data->m_value.m_valDouble, 10).ToUTF8();        // the UTF-8 buffer
#if !defined(wxJSON_USE_UNICODE)
    wxCharBuffer ansiCB(str.c_str());        // the ANSI buffer    
    if (m_noUtf8)    
    {
        writeBuff = ansiCB.data();
    }
    else    
    {
        writeBuff = utf8CB.data();
    }
   #else
       writeBuff = utf8CB.data();
   #endif
        
    // NOTE: in ANSI builds UTF-8 conversion may fail (see samples/test5.cpp,
    // test 7.3) although I do not know why
    if (writeBuff == 0)    
    {
        const char* err = "<wxJSONWriter::WriteComment(): error converting the double to UTF-8>";
        os.Write(err, strlen(err));
        return 0;
    }
    size_t len = strlen(writeBuff);
    
    os.Write(writeBuff, len);
    if (os.GetLastError() != wxSTREAM_NO_ERROR)    
    {
        r = -1;
    }
    return r;
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:54,代码来源:jsonwriter.cpp

示例11: ansiCB

/*!
 The function writes the wxString object \c str to the output object.
 The string is written as is; you cannot use it to write JSON strings
 to the output text.
 The function converts the string \c str to UTF-8 and writes the buffer..
*/
int
wxJSONWriter::WriteString( wxOutputStream& os, const wxString& str )
{
    wxLogTrace( writerTraceMask, _T("(%s) string to write=%s"),
                  __PRETTY_FUNCTION__, str.c_str() );
    int lastChar = 0;
    char* writeBuff = 0;

    // the buffer that has to be written is either UTF-8 or ANSI c_str() depending
    // on the 'm_noUtf8' flag
    wxCharBuffer utf8CB = str.ToUTF8();        // the UTF-8 buffer
#if !defined( wxJSON_USE_UNICODE )
    wxCharBuffer ansiCB( str.c_str());        // the ANSI buffer

    if ( m_noUtf8 )    {
        writeBuff = ansiCB.data();
    }
    else    {
        writeBuff = utf8CB.data();
    }
#else
    writeBuff = utf8CB.data();
#endif

    // NOTE: in ANSI builds UTF-8 conversion may fail (see samples/test5.cpp,
    // test 7.3) although I do not know why
    if ( writeBuff == 0 )    {
        const char* err = "<wxJSONWriter::WriteComment(): error converting the string to UTF-8>";
        os.Write( err, strlen( err ));
        return 0;
    }
    size_t len = strlen( writeBuff );

    os.Write( writeBuff, len );
    if ( os.GetLastError() != wxSTREAM_NO_ERROR )    {
        return -1;
    }

    wxLogTrace( writerTraceMask, _T("(%s) result=%d"),
                  __PRETTY_FUNCTION__, lastChar );
    return lastChar;
}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:48,代码来源:jsonwriter.cpp

示例12: SaveFile

bool wxPNMHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool WXUNUSED(verbose) )
{
    wxTextOutputStream text_stream(stream);

    //text_stream << "P6" << endl
    //<< image->GetWidth() << " " << image->GetHeight() << endl
    //<< "255" << endl;
    text_stream << wxT("P6\n") << image->GetWidth() << wxT(" ") << image->GetHeight() << wxT("\n255\n");
    stream.Write(image->GetData(),3*image->GetWidth()*image->GetHeight());

    return stream.IsOk();
}
开发者ID:erwincoumans,项目名称:wxWidgets,代码行数:12,代码来源:imagpnm.cpp

示例13: WriteString

/** @brief Write a string to an output stream
 *
 * @param out wxOutputStream&
 * @param str const char*
 * @return bool
 *
 */
static bool WriteString( wxOutputStream& out, const char* str )
{
    int len = 0;

    if (str != nullptr)
        len = strlen(str); // Need size in amount of bytes
    if (!WriteInt(out, len))
        return false;
    if (len > 0)
        out.Write((const void*)str, len);
    return true;
}
开发者ID:stahta01,项目名称:ClangLib,代码行数:19,代码来源:tokendatabase.cpp

示例14: wxASSERT

/*!
 This function is called for every value objects of DOUBLE type.
 This function uses the \n snprintf function to get the US-ASCII
 representation of the integer and simply copy it to the output stream.
 Returns -1 on stream errors or ZERO if no errors.

 Note that writing a double to a decimal ASCII representation could
 lay to unexpected results depending on the format string used in the
 conversion.
 See SetDoubleFmtString for details.
*/
int
wxJSONWriter::WriteDoubleValue( wxOutputStream& os, const wxJSONValue& value )
{
    int r = 0;

    char buffer[32];
    wxJSONRefData* data = value.GetRefData();
    wxASSERT( data );
    snprintf( buffer, 32, m_fmt, data->m_value.m_valDouble );
    size_t len = strlen( buffer );
    os.Write( buffer, len );
    if ( os.GetLastError() != wxSTREAM_NO_ERROR )    {
        r = -1;
    }
    return r;
}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:27,代码来源:jsonwriter.cpp

示例15: integers

/*!
 This function is called for every value objects of UINT type.
 This function uses the \n snprintf function to get the US-ASCII
 representation of the integer and simply copy it to the output stream.
 The function prepends a \b plus \b sign if the \c wxJSONWRITER_RECOGNIZE_UNSIGNED
 flag is set in the \c m_flags data member.
 Returns -1 on stream errors or ZERO if no errors.
*/
int
wxJSONWriter::WriteUIntValue( wxOutputStream& os, const wxJSONValue& value )
{
    int r = 0; size_t len;

    // prepend a plus sign if the style specifies that unsigned integers
    // have to be recognized by the JSON reader
    if ( m_style & wxJSONWRITER_RECOGNIZE_UNSIGNED )  {
        os.PutC( '+' );
    }

    char buffer[32];        // need to store 64-bits integers (max 20 digits)
    wxJSONRefData* data = value.GetRefData();
    wxASSERT( data );

#if defined( wxJSON_64BIT_INT )
    #if wxCHECK_VERSION(2, 9, 0 ) || !defined( wxJSON_USE_UNICODE )
        // this is fine for wxW 2.9 and for wxW 2.8 ANSI
        snprintf( buffer, 32, "%" wxLongLongFmtSpec "u",
                data->m_value.m_valUInt64 );
    #elif wxCHECK_VERSION(3, 0, 0) || !defined( wxJSON_USE_UNICODE )
        snprintf( buffer, 32, "%" wxLongLongFmtSpec "u",
             data->m_value.m_valUInt64 );
    #else
        // this is for wxW 2.8 Unicode: in order to use the cross-platform
        // format specifier, we use the wxString's sprintf() function and then
        // convert to UTF-8 before writing to the stream
        wxString s;
        s.Printf( _T("%") wxLongLongFmtSpec _T("u"),
                data->m_value.m_valInt64 );
        wxCharBuffer cb = s.ToUTF8();
        const char* cbData = cb.data();
        len = strlen( cbData );
        wxASSERT( len < 32 );
        memcpy( buffer, cbData, len );
        buffer[len] = 0;
    #endif
#else
    snprintf( buffer, 32, "%lu", data->m_value.m_valULong );
#endif
    len = strlen( buffer );
    os.Write( buffer, len );
    if ( os.GetLastError() != wxSTREAM_NO_ERROR )    {
        r = -1;
    }
    return r;
}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:55,代码来源:jsonwriter.cpp


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