Exemplo n.º 1
0
/// Tests Serialization
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseSerialize()
{
    //------Last Checked------//
    // - Dec 6, 2004
    bool ok = false;
    
    TestStream testStream;
    PowerTabOutputStream streamOut(testStream.GetOutputStream());
    
    // Write test data to stream
    FontSetting fontSettingOut(wxT("Arial"), 12, FontSetting::weightBold, true,
        true, true, wxColor(255,0,0));
    fontSettingOut.Serialize(streamOut);

    // Output must be OK before using input
    if (testStream.CheckOutputState())
    {
        PowerTabInputStream streamIn(testStream.GetInputStream());
    
        // Read test data back from stream
        FontSetting fontSettingIn;
        fontSettingIn.Deserialize(streamIn,
            PowerTabFileHeader::FILEVERSION_CURRENT);

        // Validate the data
        ok = ((fontSettingIn == fontSettingOut) 
            && (streamIn.CheckState()));
    }
    
    TEST(wxT("Serialize"), ok);
    
    return (true);
}    
/// Deserializes a file from an input stream
/// @param stream Input stream to read from
/// @return True if the document was deserialized, false if not
bool Document::Deserialize(PowerTabInputStream& stream)
{
    // Set the version
    const uint16_t version = m_header.GetVersion();

    m_scoreArray.push_back(new Score("Guitar Score"));
    m_scoreArray.push_back(new Score("Bass Score"));
    m_scoreArray[0]->Deserialize(stream, version);
    m_scoreArray[1]->Deserialize(stream, version);

    // Read the document font settings
    for (size_t fontSettingIndex = 0; fontSettingIndex < NUM_FONT_SETTINGS;
         fontSettingIndex++)
    {
        FontSetting fontSetting;
        fontSetting.Deserialize(stream, version);

        m_fontSettings[fontSettingIndex] = fontSetting;
    }

    // Read the line spacing and fade values
    stream >> m_tablatureStaffLineSpacing >> m_fadeIn >> m_fadeOut;
    return true;
}