Index: /trunk/libffado/src/libieee1394/configrom.cpp =================================================================== --- /trunk/libffado/src/libieee1394/configrom.cpp (revision 1073) +++ /trunk/libffado/src/libieee1394/configrom.cpp (revision 1154) @@ -398,5 +398,5 @@ } -const Glib::ustring +const std::string ConfigRom::getGuidString() const { @@ -405,10 +405,10 @@ ( unsigned int ) ( getGuid() >> 32 ), ( unsigned int ) ( getGuid() & 0xffffffff ) ); - Glib::ustring result = buf; + std::string result = buf; free( buf ); return result; } -const Glib::ustring +const std::string ConfigRom::getModelName() const { @@ -439,5 +439,5 @@ } -const Glib::ustring +const std::string ConfigRom::getVendorName() const { @@ -599,5 +599,5 @@ bool -ConfigRom::serialize( Glib::ustring path, Util::IOSerialize& ser ) +ConfigRom::serialize( std::string path, Util::IOSerialize& ser ) { bool result; @@ -605,6 +605,6 @@ result &= ser.write( path + "m_avcDevice", m_avcDevice ); result &= ser.write( path + "m_guid", m_guid ); - result &= ser.write( path + "m_vendorName", Glib::ustring( m_vendorName ) ); - result &= ser.write( path + "m_modelName", Glib::ustring( m_modelName ) ); + result &= ser.write( path + "m_vendorName", std::string( m_vendorName ) ); + result &= ser.write( path + "m_modelName", std::string( m_modelName ) ); result &= ser.write( path + "m_vendorId", m_vendorId ); result &= ser.write( path + "m_modelId", m_modelId ); @@ -624,5 +624,5 @@ ConfigRom* -ConfigRom::deserialize( Glib::ustring path, Util::IODeserialize& deser, Ieee1394Service& ieee1394Service ) +ConfigRom::deserialize( std::string path, Util::IODeserialize& deser, Ieee1394Service& ieee1394Service ) { ConfigRom* pConfigRom = new ConfigRom; Index: /trunk/libffado/src/libieee1394/configrom.h =================================================================== --- /trunk/libffado/src/libieee1394/configrom.h (revision 898) +++ /trunk/libffado/src/libieee1394/configrom.h (revision 1154) @@ -54,7 +54,7 @@ const fb_nodeid_t getNodeId() const; const fb_octlet_t getGuid() const; - const Glib::ustring getGuidString() const; - const Glib::ustring getModelName() const; - const Glib::ustring getVendorName() const; + const std::string getGuidString() const; + const std::string getModelName() const; + const std::string getVendorName() const; const unsigned int getModelId() const; @@ -100,6 +100,6 @@ static bool compareGUID( const ConfigRom& a, const ConfigRom& b ); - bool serialize( Glib::ustring path, Util::IOSerialize& ser ); - static ConfigRom* deserialize( Glib::ustring path, + bool serialize( std::string path, Util::IOSerialize& ser ); + static ConfigRom* deserialize( std::string path, Util::IODeserialize& deser, Ieee1394Service& ieee1394Service ); @@ -123,6 +123,6 @@ bool m_avcDevice; fb_octlet_t m_guid; - Glib::ustring m_vendorName; - Glib::ustring m_modelName; + std::string m_vendorName; + std::string m_modelName; unsigned int m_vendorId; unsigned int m_modelId; Index: /trunk/libffado/src/devicemanager.h =================================================================== --- /trunk/libffado/src/devicemanager.h (revision 967) +++ /trunk/libffado/src/devicemanager.h (revision 1154) @@ -35,6 +35,4 @@ #include "libutil/OptionContainer.h" #include "libcontrol/BasicElements.h" - -#include #include "libutil/Functors.h" Index: /trunk/libffado/src/SConscript =================================================================== --- /trunk/libffado/src/SConscript (revision 1066) +++ /trunk/libffado/src/SConscript (revision 1154) @@ -78,5 +78,4 @@ libutil/PosixThread.cpp \ libutil/ringbuffer.c \ - libutil/serialize.cpp \ libutil/StreamStatistics.cpp \ libutil/SystemTimeSource.cpp \ @@ -89,4 +88,11 @@ libcontrol/Nickname.cpp \ ') + +if env['SERIALIZE_USE_EXPAT']: + ffado_source.append('libutil/serialize_expat.cpp') + ffado_source.append('libutil/serialize_expat_xml.cpp') +else: + ffado_source.append('libutil/serialize_libxml.cpp') + bebob_source = env.Split( '\ @@ -216,5 +222,8 @@ libenv.MergeFlags( env['LIBAVC1394_FLAGS'] ) libenv.MergeFlags( env['LIBIEC61883_FLAGS'] ) - libenv.MergeFlags( env['LIBXML26_FLAGS'] ) + if not env['SERIALIZE_USE_EXPAT']: + libenv.MergeFlags( env['LIBXML26_FLAGS'] ) + else: + libenv.PrependUnique( LIBS=["expat"] ) #env1.AppendUnique( LINKFLAGS = env.Split("-Wl,-rpath $libdir -Wl,-soname -Wl,libffado.so.1 --version-info=1:0:0") ) Index: /trunk/libffado/src/libavc/musicsubunit/avc_musicsubunit.cpp =================================================================== --- /trunk/libffado/src/libavc/musicsubunit/avc_musicsubunit.cpp (revision 1110) +++ /trunk/libffado/src/libavc/musicsubunit/avc_musicsubunit.cpp (revision 1154) @@ -304,5 +304,5 @@ bool -SubunitMusic::serializeChild( Glib::ustring basePath, +SubunitMusic::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -311,5 +311,5 @@ bool -SubunitMusic::deserializeChild( Glib::ustring basePath, +SubunitMusic::deserializeChild( std::string basePath, Util::IODeserialize& deser, Unit& unit ) @@ -319,5 +319,5 @@ bool -SubunitMusic::deserializeUpdateChild( Glib::ustring basePath, +SubunitMusic::deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ) { Index: /trunk/libffado/src/libavc/musicsubunit/avc_musicsubunit.h =================================================================== --- /trunk/libffado/src/libavc/musicsubunit/avc_musicsubunit.h (revision 1110) +++ /trunk/libffado/src/libavc/musicsubunit/avc_musicsubunit.h (revision 1154) @@ -54,10 +54,10 @@ virtual const char* getName(); protected: - virtual bool serializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, Unit& avDevice ); - virtual bool deserializeUpdateChild( Glib::ustring basePath, + virtual bool deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ); Index: /trunk/libffado/src/libavc/audiosubunit/avc_audiosubunit.h =================================================================== --- /trunk/libffado/src/libavc/audiosubunit/avc_audiosubunit.h (revision 1110) +++ /trunk/libffado/src/libavc/audiosubunit/avc_audiosubunit.h (revision 1154) @@ -51,10 +51,10 @@ protected: - virtual bool serializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, Util::IOSerialize& ser ) const { return true; } - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, Unit& avDevice ) { return true; } - virtual bool deserializeUpdateChild( Glib::ustring basePath, + virtual bool deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ) { return true; } Index: /trunk/libffado/src/libavc/general/avc_plug.cpp =================================================================== --- /trunk/libffado/src/libavc/general/avc_plug.cpp (revision 1110) +++ /trunk/libffado/src/libavc/general/avc_plug.cpp (revision 1154) @@ -1428,5 +1428,5 @@ bool -Plug::serializeChannelInfos( Glib::ustring basePath, +Plug::serializeChannelInfos( std::string basePath, Util::IOSerialize& ser, const ClusterInfo& clusterInfo ) const @@ -1452,5 +1452,5 @@ bool -Plug::deserializeChannelInfos( Glib::ustring basePath, +Plug::deserializeChannelInfos( std::string basePath, Util::IODeserialize& deser, ClusterInfo& clusterInfo ) @@ -1488,5 +1488,5 @@ bool -Plug::serializeClusterInfos( Glib::ustring basePath, +Plug::serializeClusterInfos( std::string basePath, Util::IOSerialize& ser ) const { @@ -1514,5 +1514,5 @@ bool -Plug::deserializeClusterInfos( Glib::ustring basePath, +Plug::deserializeClusterInfos( std::string basePath, Util::IODeserialize& deser ) { @@ -1552,5 +1552,5 @@ bool -Plug::serializeFormatInfos( Glib::ustring basePath, +Plug::serializeFormatInfos( std::string basePath, Util::IOSerialize& ser ) const { @@ -1576,5 +1576,5 @@ bool -Plug::deserializeFormatInfos( Glib::ustring basePath, +Plug::deserializeFormatInfos( std::string basePath, Util::IODeserialize& deser ) { @@ -1612,5 +1612,5 @@ bool -Plug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const +Plug::serialize( std::string basePath, Util::IOSerialize& ser ) const { bool result=true; @@ -1637,5 +1637,5 @@ Plug* -Plug::deserialize( Glib::ustring basePath, +Plug::deserialize( std::string basePath, Util::IODeserialize& deser, Unit& unit, @@ -1692,5 +1692,5 @@ bool -Plug::deserializeConnections( Glib::ustring basePath, +Plug::deserializeConnections( std::string basePath, Util::IODeserialize& deser ) { @@ -2151,5 +2151,5 @@ bool -PlugManager::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const +PlugManager::serialize( std::string basePath, Util::IOSerialize& ser ) const { bool result = true; @@ -2170,5 +2170,5 @@ PlugManager* -PlugManager::deserialize( Glib::ustring basePath, +PlugManager::deserialize( std::string basePath, Util::IODeserialize& deser, Unit& unit ) @@ -2202,5 +2202,5 @@ bool -PlugManager::deserializeUpdate( Glib::ustring basePath, +PlugManager::deserializeUpdate( std::string basePath, Util::IODeserialize& deser) { @@ -2239,5 +2239,5 @@ bool -PlugConnection::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const +PlugConnection::serialize( std::string basePath, Util::IOSerialize& ser ) const { bool result; @@ -2248,5 +2248,5 @@ PlugConnection* -PlugConnection::deserialize( Glib::ustring basePath, +PlugConnection::deserialize( std::string basePath, Util::IODeserialize& deser, Unit& unit ) @@ -2358,5 +2358,5 @@ bool -serializePlugVector( Glib::ustring basePath, +serializePlugVector( std::string basePath, Util::IOSerialize& ser, const PlugVector& vec) @@ -2379,5 +2379,5 @@ bool -deserializePlugVector( Glib::ustring basePath, +deserializePlugVector( std::string basePath, Util::IODeserialize& deser, const PlugManager& plugManager, Index: /trunk/libffado/src/libavc/general/avc_plug.h =================================================================== --- /trunk/libffado/src/libavc/general/avc_plug.h (revision 864) +++ /trunk/libffado/src/libavc/general/avc_plug.h (revision 1154) @@ -35,5 +35,5 @@ #include "debugmodule/debugmodule.h" -#include +#include class Ieee1394Service; @@ -155,10 +155,10 @@ void showPlug() const; - bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - static Plug* deserialize( Glib::ustring basePath, + bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + static Plug* deserialize( std::string basePath, Util::IODeserialize& deser, Unit& avDevice, PlugManager& plugManager ); - bool deserializeConnections( Glib::ustring basePath, + bool deserializeConnections( std::string basePath, Util::IODeserialize& deser ); bool deserializeUpdateSubunit(); @@ -168,5 +168,5 @@ stream_position_t m_streamPosition; stream_position_location_t m_location; - Glib::ustring m_name; + std::string m_name; }; typedef std::vector ChannelInfoVector; @@ -175,5 +175,5 @@ int m_index; port_type_t m_portType; - Glib::ustring m_name; + std::string m_name; nr_of_channels_t m_nrOfChannels; @@ -240,19 +240,19 @@ const ClusterInfo* getClusterInfoByIndex( int index ) const; - bool serializeChannelInfos( Glib::ustring basePath, + bool serializeChannelInfos( std::string basePath, Util::IOSerialize& ser, const ClusterInfo& clusterInfo ) const; - bool deserializeChannelInfos( Glib::ustring basePath, + bool deserializeChannelInfos( std::string basePath, Util::IODeserialize& deser, ClusterInfo& clusterInfo ); - bool serializeClusterInfos( Glib::ustring basePath, + bool serializeClusterInfos( std::string basePath, Util::IOSerialize& ser ) const; - bool deserializeClusterInfos( Glib::ustring basePath, + bool deserializeClusterInfos( std::string basePath, Util::IODeserialize& deser ); - bool serializeFormatInfos( Glib::ustring basePath, + bool serializeFormatInfos( std::string basePath, Util::IOSerialize& ser ) const; - bool deserializeFormatInfos( Glib::ustring basePath, + bool deserializeFormatInfos( std::string basePath, Util::IODeserialize& deser ); @@ -287,5 +287,5 @@ EPlugType m_infoPlugType; nr_of_channels_t m_nrOfChannels; - Glib::ustring m_name; + std::string m_name; ClusterInfoVector m_clusterInfos; sampling_frequency_t m_samplingFrequency; @@ -334,6 +334,6 @@ Plug::EPlugType type) const; - bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - static PlugManager* deserialize( Glib::ustring basePath, + bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + static PlugManager* deserialize( std::string basePath, Util::IODeserialize& deser, Unit& avDevice ); @@ -343,5 +343,5 @@ bool tidyPlugConnections(PlugConnectionVector&); - bool deserializeUpdate( Glib::ustring basePath, + bool deserializeUpdate( std::string basePath, Util::IODeserialize& deser ); @@ -362,6 +362,6 @@ { return *m_destPlug; } - bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - static PlugConnection* deserialize( Glib::ustring basePath, + bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + static PlugConnection* deserialize( std::string basePath, Util::IODeserialize& deser, Unit& avDevice ); @@ -377,9 +377,9 @@ -bool serializePlugVector( Glib::ustring basePath, +bool serializePlugVector( std::string basePath, Util::IOSerialize& ser, const PlugVector& vec); -bool deserializePlugVector( Glib::ustring basePath, +bool deserializePlugVector( std::string basePath, Util::IODeserialize& deser, const PlugManager& plugManager, Index: /trunk/libffado/src/libavc/general/avc_unit.cpp =================================================================== --- /trunk/libffado/src/libavc/general/avc_unit.cpp (revision 1110) +++ /trunk/libffado/src/libavc/general/avc_unit.cpp (revision 1154) @@ -845,5 +845,5 @@ template bool -serializeVector( Glib::ustring path, +serializeVector( std::string path, Util::IOSerialize& ser, const T& vec ) @@ -862,5 +862,5 @@ template bool -deserializeVector( Glib::ustring path, +deserializeVector( std::string path, Util::IODeserialize& deser, Unit& unit, @@ -885,5 +885,5 @@ bool -Unit::serializeSyncInfoVector( Glib::ustring basePath, +Unit::serializeSyncInfoVector( std::string basePath, Util::IOSerialize& ser, const SyncInfoVector& vec ) const @@ -903,5 +903,5 @@ result &= ser.write( strstrm.str() + "m_source", info.m_source->getGlobalId() ); result &= ser.write( strstrm.str() + "m_destination", info.m_destination->getGlobalId() ); - result &= ser.write( strstrm.str() + "m_description", Glib::ustring( info.m_description ) ); + result &= ser.write( strstrm.str() + "m_description", std::string( info.m_description ) ); i++; @@ -912,5 +912,5 @@ bool -Unit::deserializeSyncInfoVector( Glib::ustring basePath, +Unit::deserializeSyncInfoVector( std::string basePath, Util::IODeserialize& deser, SyncInfoVector& vec ) @@ -925,5 +925,5 @@ plug_id_t sourceId; plug_id_t destinationId; - Glib::ustring description; + std::string description; if ( deser.isExisting( strstrm.str() + "m_source" ) ) { @@ -952,5 +952,5 @@ bool -Unit::serialize( Glib::ustring basePath, +Unit::serialize( std::string basePath, Util::IOSerialize& ser ) const { @@ -980,5 +980,5 @@ bool -Unit::deserialize( Glib::ustring basePath, +Unit::deserialize( std::string basePath, Util::IODeserialize& deser ) { Index: /trunk/libffado/src/libavc/general/avc_unit.h =================================================================== --- /trunk/libffado/src/libavc/general/avc_unit.h (revision 864) +++ /trunk/libffado/src/libavc/general/avc_unit.h (revision 1154) @@ -93,6 +93,6 @@ virtual bool setActiveSync( const SyncInfo& syncInfo ); - virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - virtual bool deserialize( Glib::ustring basePath, Util::IODeserialize& deser ); + virtual bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + virtual bool deserialize( std::string basePath, Util::IODeserialize& deser ); SubunitAudio* getAudioSubunit( subunit_id_t subunitId ) @@ -152,8 +152,8 @@ - bool serializeSyncInfoVector( Glib::ustring basePath, + bool serializeSyncInfoVector( std::string basePath, Util::IOSerialize& ser, const SyncInfoVector& vec ) const; - bool deserializeSyncInfoVector( Glib::ustring basePath, + bool deserializeSyncInfoVector( std::string basePath, Util::IODeserialize& deser, SyncInfoVector& vec ); Index: /trunk/libffado/src/libavc/general/avc_subunit.cpp =================================================================== --- /trunk/libffado/src/libavc/general/avc_subunit.cpp (revision 1110) +++ /trunk/libffado/src/libavc/general/avc_subunit.cpp (revision 1154) @@ -231,5 +231,5 @@ bool -Subunit::serialize( Glib::ustring basePath, +Subunit::serialize( std::string basePath, Util::IOSerialize& ser ) const { @@ -245,5 +245,5 @@ Subunit* -Subunit::deserialize( Glib::ustring basePath, +Subunit::deserialize( std::string basePath, Util::IODeserialize& deser, Unit& unit ) @@ -278,5 +278,5 @@ bool -Subunit::deserializeUpdate( Glib::ustring basePath, +Subunit::deserializeUpdate( std::string basePath, Util::IODeserialize& deser ) { Index: /trunk/libffado/src/libavc/general/avc_subunit.h =================================================================== --- /trunk/libffado/src/libavc/general/avc_subunit.h (revision 1110) +++ /trunk/libffado/src/libavc/general/avc_subunit.h (revision 1154) @@ -78,8 +78,8 @@ virtual void setVerboseLevel(int l); - bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - static Subunit* deserialize( Glib::ustring basePath, + bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + static Subunit* deserialize( std::string basePath, Util::IODeserialize& deser, Unit& avDevice ); - bool deserializeUpdate( Glib::ustring basePath, + bool deserializeUpdate( std::string basePath, Util::IODeserialize& deser ); @@ -87,10 +87,10 @@ Subunit(); - virtual bool serializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, Util::IOSerialize& ser ) const = 0; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, Unit& avDevice ) = 0; - virtual bool deserializeUpdateChild( Glib::ustring basePath, + virtual bool deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ) = 0; Index: /trunk/libffado/src/libutil/serialize_libxml.cpp =================================================================== --- /trunk/libffado/src/libutil/serialize_libxml.cpp (revision 1154) +++ /trunk/libffado/src/libutil/serialize_libxml.cpp (revision 1154) @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2005-2008 by Daniel Wagner + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "config.h" // FOR CACHE_VERSION + +#include "serialize.h" + +using namespace std; + + +IMPL_DEBUG_MODULE( Util::XMLSerialize, XMLSerialize, DEBUG_LEVEL_NORMAL ); +IMPL_DEBUG_MODULE( Util::XMLDeserialize, XMLDeserialize, DEBUG_LEVEL_NORMAL ); + +Util::XMLSerialize::XMLSerialize( std::string fileName ) + : IOSerialize() + , m_filepath( fileName ) + , m_verboseLevel( DEBUG_LEVEL_NORMAL ) +{ + setDebugLevel( DEBUG_LEVEL_NORMAL ); + try { + m_doc.create_root_node( "ffado_cache" ); + writeVersion(); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLSerialize::XMLSerialize( std::string fileName, int verboseLevel ) + : IOSerialize() + , m_filepath( fileName ) + , m_verboseLevel( verboseLevel ) +{ + setDebugLevel(verboseLevel); + try { + m_doc.create_root_node( "ffado_cache" ); + writeVersion(); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLSerialize::~XMLSerialize() +{ + try { + m_doc.write_to_file_formatted( m_filepath ); + } catch ( const exception& ex ) { + cout << "Exception caugth: " << ex.what(); + } + +} + +void +Util::XMLSerialize::writeVersion() +{ + xmlpp::Node* pNode = m_doc.get_root_node(); + xmlpp::Element* pElem = pNode->add_child( "CacheVersion" ); + char* valstr; + asprintf( &valstr, "%s", CACHE_VERSION ); + pElem->set_child_text( valstr ); + free( valstr ); +} + +bool +Util::XMLSerialize::write( std::string strMemberName, + long long value ) + +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %d\n", + strMemberName.c_str(), value ); + + vector tokens; + tokenize( strMemberName, tokens, "/" ); + + if ( tokens.size() == 0 ) { + debugWarning( "token size is 0\n" ); + return false; + } + + xmlpp::Node* pNode = m_doc.get_root_node(); + pNode = getNodePath( pNode, tokens ); + + // element to be added + xmlpp::Element* pElem = pNode->add_child( tokens[tokens.size() - 1] ); + char* valstr; + asprintf( &valstr, "%lld", value ); + pElem->set_child_text( valstr ); + free( valstr ); + + return true; +} + +bool +Util::XMLSerialize::write( std::string strMemberName, + std::string str) +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %s\n", + strMemberName.c_str(), str.c_str() ); + + vector tokens; + tokenize( strMemberName, tokens, "/" ); + + if ( tokens.size() == 0 ) { + debugWarning( "token size is 0\n" ); + return false; + } + + xmlpp::Node* pNode = m_doc.get_root_node(); + pNode = getNodePath( pNode, tokens ); + + // element to be added + xmlpp::Element* pElem = pNode->add_child( tokens[tokens.size() - 1] ); + pElem->set_child_text( str ); + + return true; +} + +xmlpp::Node* +Util::XMLSerialize::getNodePath( xmlpp::Node* pRootNode, + std::vector& tokens ) +{ + // returns the correct node on which the new element has to be added. + // if the path does not exist, it will be created. + + if ( tokens.size() == 1 ) { + return pRootNode; + } + + unsigned int iTokenIdx = 0; + xmlpp::Node* pCurNode = pRootNode; + for (bool bFound = false; + ( iTokenIdx < tokens.size() - 1 ); + bFound = false, iTokenIdx++ ) + { + xmlpp::Node::NodeList nodeList = pCurNode->get_children(); + for ( xmlpp::Node::NodeList::iterator it = nodeList.begin(); + it != nodeList.end(); + ++it ) + { + if ( ( *it )->get_name() == tokens[iTokenIdx] ) { + pCurNode = *it; + bFound = true; + break; + } + } + if ( !bFound ) { + break; + } + } + + for ( unsigned int i = iTokenIdx; i < tokens.size() - 1; i++, iTokenIdx++ ) { + pCurNode = pCurNode->add_child( tokens[iTokenIdx] ); + } + return pCurNode; + +} + +/***********************************/ + +Util::XMLDeserialize::XMLDeserialize( std::string fileName ) + : IODeserialize() + , m_filepath( fileName ) + , m_verboseLevel( DEBUG_LEVEL_NORMAL ) +{ + setDebugLevel(DEBUG_LEVEL_NORMAL); + try { + m_parser.set_substitute_entities(); //We just want the text to + //be resolved/unescaped + //automatically. + m_parser.parse_file( m_filepath ); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLDeserialize::XMLDeserialize( std::string fileName, int verboseLevel ) + : IODeserialize() + , m_filepath( fileName ) + , m_verboseLevel( verboseLevel ) +{ + setDebugLevel(verboseLevel); + try { + m_parser.set_substitute_entities(); //We just want the text to + //be resolved/unescaped + //automatically. + m_parser.parse_file( m_filepath ); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLDeserialize::~XMLDeserialize() +{ +} + +bool +Util::XMLDeserialize::isValid() +{ + return checkVersion(); +} + +bool +Util::XMLDeserialize::checkVersion() +{ + std::string savedVersion; + if (read( "CacheVersion", savedVersion )) { + Glib::ustring expectedVersion = CACHE_VERSION; + debugOutput( DEBUG_LEVEL_NORMAL, "Cache version: %s, expected: %s.\n", savedVersion.c_str(), expectedVersion.c_str() ); + if (expectedVersion == savedVersion) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version OK.\n" ); + return true; + } else { + debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version not OK.\n" ); + return false; + } + } else return false; +} + +bool +Util::XMLDeserialize::read( std::string strMemberName, + long long& value ) + +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "lookup %s\n", strMemberName.c_str() ); + + xmlpp::Document *pDoc=m_parser.get_document(); + if(!pDoc) { + debugWarning( "no document found\n" ); + return false; + } + xmlpp::Node* pNode = pDoc->get_root_node(); + + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "pNode = %s\n", pNode->get_name().c_str() ); + + xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); + for ( xmlpp::NodeSet::iterator it = nodeSet.begin(); + it != nodeSet.end(); + ++it ) + { + const xmlpp::Element* pElement = + dynamic_cast< const xmlpp::Element* >( *it ); + if ( pElement && pElement->has_child_text() ) { + char* tail; + value = strtoll( pElement->get_child_text()->get_content().c_str(), + &tail, 0 ); + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %d\n", + strMemberName.c_str(), value ); + return true; + } + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; + } + + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; +} + +bool +Util::XMLDeserialize::read( std::string strMemberName, + std::string& str ) +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "lookup %s\n", strMemberName.c_str() ); + + xmlpp::Document *pDoc=m_parser.get_document(); + if(!pDoc) { + debugWarning( "no document found\n" ); + return false; + } + xmlpp::Node* pNode = pDoc->get_root_node(); + + xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); + for ( xmlpp::NodeSet::iterator it = nodeSet.begin(); + it != nodeSet.end(); + ++it ) + { + const xmlpp::Element* pElement = dynamic_cast< const xmlpp::Element* >( *it ); + if ( pElement ) { + if ( pElement->has_child_text() ) { + str = pElement->get_child_text()->get_content(); + } else { + str = ""; + } + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %s\n", + strMemberName.c_str(), str.c_str() ); + return true; + } + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; + } + + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; +} + +bool +Util::XMLDeserialize::isExisting( std::string strMemberName ) +{ + xmlpp::Document *pDoc=m_parser.get_document(); + if(!pDoc) { + return false; + } + xmlpp::Node* pNode = pDoc->get_root_node(); + xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); + return nodeSet.size() > 0; +} + +void +tokenize(const string& str, + vector& tokens, + const string& delimiters) +{ + // Skip delimiters at beginning. + string::size_type lastPos = str.find_first_not_of(delimiters, 0); + // Find first "non-delimiter". + string::size_type pos = str.find_first_of(delimiters, lastPos); + + while (string::npos != pos || string::npos != lastPos) + { + // Found a token, add it to the vector. + tokens.push_back(str.substr(lastPos, pos - lastPos)); + // Skip delimiters. Note the "not_of" + lastPos = str.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = str.find_first_of(delimiters, lastPos); + } +} Index: /trunk/libffado/src/libutil/unittests.cpp =================================================================== --- /trunk/libffado/src/libutil/unittests.cpp (revision 864) +++ /trunk/libffado/src/libutil/unittests.cpp (revision 1154) @@ -366,5 +366,5 @@ { bool result; - result = ser.write( "m_pString", Glib::ustring( m_pString ) ); + result = ser.write( "m_pString", std::string( m_pString ) ); return result; } @@ -374,5 +374,5 @@ { bool result; - Glib::ustring str; + std::string str; result = deser.read( "m_pString", str ); Index: /trunk/libffado/src/libutil/OptionContainer.cpp =================================================================== --- /trunk/libffado/src/libutil/OptionContainer.cpp (revision 864) +++ /trunk/libffado/src/libutil/OptionContainer.cpp (revision 1154) @@ -108,9 +108,9 @@ bool -OptionContainer::Option::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const +OptionContainer::Option::serialize( std::string basePath, Util::IOSerialize& ser ) const { bool result; - result = ser.write( basePath + "m_Name", Glib::ustring(m_Name) ); - result &= ser.write( basePath + "m_stringValue", Glib::ustring(m_stringValue) ); + result = ser.write( basePath + "m_Name", std::string(m_Name) ); + result &= ser.write( basePath + "m_stringValue", std::string(m_stringValue) ); result &= ser.write( basePath + "m_boolValue", m_boolValue ); result &= ser.write( basePath + "m_doubleValue", m_doubleValue ); @@ -124,10 +124,10 @@ OptionContainer::Option -OptionContainer::Option::deserialize( Glib::ustring basePath, +OptionContainer::Option::deserialize( std::string basePath, Util::IODeserialize& deser ) { bool result; Option op=Option(); - Glib::ustring tmpstr; + std::string tmpstr; result = deser.read( basePath + "m_Name", tmpstr ); @@ -412,5 +412,5 @@ bool -OptionContainer::serializeOptions( Glib::ustring basePath, +OptionContainer::serializeOptions( std::string basePath, Util::IOSerialize& ser) const { @@ -434,5 +434,5 @@ bool -OptionContainer::deserializeOptions( Glib::ustring basePath, +OptionContainer::deserializeOptions( std::string basePath, Util::IODeserialize& deser, OptionContainer& container) Index: /trunk/libffado/src/libutil/serialize.h =================================================================== --- /trunk/libffado/src/libutil/serialize.h (revision 864) +++ /trunk/libffado/src/libutil/serialize.h (revision 1154) @@ -1,4 +1,4 @@ /* - * Copyright (C) 2005-2008 by Daniel Wagner + * Copyright (C) 2008 by Pieter Palmers * * This file is part of FFADO @@ -22,108 +22,14 @@ */ -#ifndef bebob_serialize_h -#define bebob_serialize_h +#ifndef __FFADO_UTIL_SERIALIZE_H__ +#define __FFADO_UTIL_SERIALIZE_H__ -#include "debugmodule/debugmodule.h" +#include "config.h" -#include - -#include - -namespace Util { - - class IOSerialize { - public: - IOSerialize() {} - virtual ~IOSerialize() {} - - virtual bool write( std::string strMemberName, - long long value ) = 0; - virtual bool write( std::string strMemberName, - Glib::ustring str) = 0; - - template bool write( std::string strMemberName, T value ); - }; - - class IODeserialize { - public: - IODeserialize() {} - virtual ~IODeserialize() {} - - virtual bool read( std::string strMemberName, - long long& value ) = 0; - virtual bool read( std::string strMemberName, - Glib::ustring& str ) = 0; - - template bool read( std::string strMemberName, T& value ); - - virtual bool isExisting( std::string strMemberName ) = 0; - }; - - class XMLSerialize: public IOSerialize { - public: - XMLSerialize( Glib::ustring fileName ); - XMLSerialize( Glib::ustring fileName, int verboseLevel ); - virtual ~XMLSerialize(); - - virtual bool write( std::string strMemberName, - long long value ); - virtual bool write( std::string strMemberName, - Glib::ustring str); - private: - void writeVersion(); - - Glib::ustring m_filepath; - xmlpp::Document m_doc; - int m_verboseLevel; - - DECLARE_DEBUG_MODULE; - - xmlpp::Node* getNodePath( xmlpp::Node* pRootNode, - std::vector& tokens ); - }; - - class XMLDeserialize: public IODeserialize { - public: - XMLDeserialize( Glib::ustring fileName ); - XMLDeserialize( Glib::ustring fileName, int verboseLevel ); - virtual ~XMLDeserialize(); - - virtual bool read( std::string strMemberName, - long long& value ); - virtual bool read( std::string strMemberName, - Glib::ustring& str ); - - virtual bool isExisting( std::string strMemberName ); - bool isValid(); - bool checkVersion(); - private: - Glib::ustring m_filepath; - xmlpp::DomParser m_parser; - int m_verboseLevel; - - DECLARE_DEBUG_MODULE; - }; - - -////////////////////////////////////////// - - template bool IOSerialize::write( std::string strMemberName, - T value ) - { - return write( strMemberName, static_cast( value ) ); - } - - template bool IODeserialize::read( std::string strMemberName, - T& value ) - { - long long tmp; - bool result = read( strMemberName, tmp ); - value = static_cast( tmp ); - return result; - } -} - -void tokenize(const std::string& str, std::vector& tokens, const std::string& delimiters = " "); +#if SERIALIZE_USE_EXPAT + #include "serialize_expat.h" +#else + #include "serialize_libxml.h" +#endif #endif Index: /trunk/libffado/src/libutil/serialize_expat.h =================================================================== --- /trunk/libffado/src/libutil/serialize_expat.h (revision 1154) +++ /trunk/libffado/src/libutil/serialize_expat.h (revision 1154) @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2005-2008 by Daniel Wagner + * Copyright (C) 2005-2008 by Pieter Palmers + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef __FFADO_UTIL_SERIALIZE_EXPAT_H__ +#define __FFADO_UTIL_SERIALIZE_EXPAT_H__ + +#include "debugmodule/debugmodule.h" + +#include "serialize_expat_xml.h" + +#include +#include + +namespace Util { + + class IOSerialize { + public: + IOSerialize() {} + virtual ~IOSerialize() {} + + virtual bool write( std::string strMemberName, + long long value ) = 0; + virtual bool write( std::string strMemberName, + std::string str) = 0; + + template bool write( std::string strMemberName, T value ); + }; + + class IODeserialize { + public: + IODeserialize() {} + virtual ~IODeserialize() {} + + virtual bool read( std::string strMemberName, + long long& value ) = 0; + virtual bool read( std::string strMemberName, + std::string& str ) = 0; + + template bool read( std::string strMemberName, T& value ); + + virtual bool isExisting( std::string strMemberName ) = 0; + }; + + class XMLSerialize: public IOSerialize { + public: + XMLSerialize( std::string fileName ); + XMLSerialize( std::string fileName, int verboseLevel ); + virtual ~XMLSerialize(); + + virtual bool write( std::string strMemberName, + long long value ); + virtual bool write( std::string strMemberName, + std::string str); + private: + void writeVersion(); + + std::string m_filepath; + Xml::Document m_doc; + int m_verboseLevel; + + DECLARE_DEBUG_MODULE; + + Xml::Node* getNodePath( Xml::Node* pRootNode, + std::vector& tokens ); + }; + + class XMLDeserialize: public IODeserialize { + public: + XMLDeserialize( std::string fileName ); + XMLDeserialize( std::string fileName, int verboseLevel ); + virtual ~XMLDeserialize(); + + virtual bool read( std::string strMemberName, + long long& value ); + virtual bool read( std::string strMemberName, + std::string& str ); + + virtual bool isExisting( std::string strMemberName ); + bool isValid(); + bool checkVersion(); + private: + std::string m_filepath; + Xml::Document m_doc; + int m_verboseLevel; + + DECLARE_DEBUG_MODULE; + }; + + +////////////////////////////////////////// + + template bool IOSerialize::write( std::string strMemberName, + T value ) + { + return write( strMemberName, static_cast( value ) ); + } + + template bool IODeserialize::read( std::string strMemberName, + T& value ) + { + long long tmp; + bool result = read( strMemberName, tmp ); + value = static_cast( tmp ); + return result; + } +} + +void tokenize(const std::string& str, std::vector& tokens, const std::string& delimiters = " "); + +#endif Index: /trunk/libffado/src/libutil/serialize_libxml.h =================================================================== --- /trunk/libffado/src/libutil/serialize_libxml.h (revision 1154) +++ /trunk/libffado/src/libutil/serialize_libxml.h (revision 1154) @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2005-2008 by Daniel Wagner + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef __FFADO_UTIL_SERIALIZE_XMLPP_H__ +#define __FFADO_UTIL_SERIALIZE_XMLPP_H__ + +#include "debugmodule/debugmodule.h" + +#include + +#include +#include + +namespace Util { + + class IOSerialize { + public: + IOSerialize() {} + virtual ~IOSerialize() {} + + virtual bool write( std::string strMemberName, + long long value ) = 0; + virtual bool write( std::string strMemberName, + std::string str) = 0; + + template bool write( std::string strMemberName, T value ); + }; + + class IODeserialize { + public: + IODeserialize() {} + virtual ~IODeserialize() {} + + virtual bool read( std::string strMemberName, + long long& value ) = 0; + virtual bool read( std::string strMemberName, + std::string& str ) = 0; + + template bool read( std::string strMemberName, T& value ); + + virtual bool isExisting( std::string strMemberName ) = 0; + }; + + class XMLSerialize: public IOSerialize { + public: + XMLSerialize( std::string fileName ); + XMLSerialize( std::string fileName, int verboseLevel ); + virtual ~XMLSerialize(); + + virtual bool write( std::string strMemberName, + long long value ); + virtual bool write( std::string strMemberName, + std::string str); + private: + void writeVersion(); + + std::string m_filepath; + xmlpp::Document m_doc; + int m_verboseLevel; + + DECLARE_DEBUG_MODULE; + + xmlpp::Node* getNodePath( xmlpp::Node* pRootNode, + std::vector& tokens ); + }; + + class XMLDeserialize: public IODeserialize { + public: + XMLDeserialize( std::string fileName ); + XMLDeserialize( std::string fileName, int verboseLevel ); + virtual ~XMLDeserialize(); + + virtual bool read( std::string strMemberName, + long long& value ); + virtual bool read( std::string strMemberName, + std::string& str ); + + virtual bool isExisting( std::string strMemberName ); + bool isValid(); + bool checkVersion(); + private: + std::string m_filepath; + xmlpp::DomParser m_parser; + int m_verboseLevel; + + DECLARE_DEBUG_MODULE; + }; + + +////////////////////////////////////////// + + template bool IOSerialize::write( std::string strMemberName, + T value ) + { + return write( strMemberName, static_cast( value ) ); + } + + template bool IODeserialize::read( std::string strMemberName, + T& value ) + { + long long tmp; + bool result = read( strMemberName, tmp ); + value = static_cast( tmp ); + return result; + } +} + +void tokenize(const std::string& str, std::vector& tokens, const std::string& delimiters = " "); + +#endif Index: /trunk/libffado/src/libutil/OptionContainer.h =================================================================== --- /trunk/libffado/src/libutil/OptionContainer.h (revision 864) +++ /trunk/libffado/src/libutil/OptionContainer.h (revision 1154) @@ -74,6 +74,6 @@ public: // serialization support - bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - static Option deserialize( Glib::ustring basePath, + bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + static Option deserialize( std::string basePath, Util::IODeserialize& deser); private: @@ -153,7 +153,7 @@ protected: // serialization support - bool serializeOptions( Glib::ustring basePath, + bool serializeOptions( std::string basePath, Util::IOSerialize& ser) const; - static bool deserializeOptions( Glib::ustring basePath, + static bool deserializeOptions( std::string basePath, Util::IODeserialize& deser, OptionContainer& container); Index: /trunk/libffado/src/libutil/serialize_expat.cpp =================================================================== --- /trunk/libffado/src/libutil/serialize_expat.cpp (revision 1154) +++ /trunk/libffado/src/libutil/serialize_expat.cpp (revision 1154) @@ -0,0 +1,369 @@ +/* + * Copyright (C) 2005-2008 by Daniel Wagner + * Copyright (C) 2005-2008 by Pieter Palmers + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "config.h" // FOR CACHE_VERSION + +#include "serialize.h" + +using namespace std; + + +IMPL_DEBUG_MODULE( Util::XMLSerialize, XMLSerialize, DEBUG_LEVEL_NORMAL ); +IMPL_DEBUG_MODULE( Util::XMLDeserialize, XMLDeserialize, DEBUG_LEVEL_NORMAL ); + +Util::XMLSerialize::XMLSerialize( std::string fileName ) + : IOSerialize() + , m_filepath( fileName ) + , m_verboseLevel( DEBUG_LEVEL_NORMAL ) +{ + setDebugLevel( DEBUG_LEVEL_NORMAL ); + try { + m_doc.create_root_node( "ffado_cache" ); + writeVersion(); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLSerialize::XMLSerialize( std::string fileName, int verboseLevel ) + : IOSerialize() + , m_filepath( fileName ) + , m_verboseLevel( verboseLevel ) +{ + setDebugLevel(verboseLevel); + try { + m_doc.create_root_node( "ffado_cache" ); + writeVersion(); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLSerialize::~XMLSerialize() +{ + try { + m_doc.write_to_file_formatted( m_filepath ); + } catch ( const exception& ex ) { + cout << "Exception caugth: " << ex.what(); + } + +} + +void +Util::XMLSerialize::writeVersion() +{ + Xml::Node* pNode = m_doc.get_root_node(); + if(pNode) { + char* valstr; + asprintf( &valstr, "%s", CACHE_VERSION ); + + // check whether we already have a version node + Xml::Nodes versionfields = (*pNode)["CacheVersion"]; + + if(versionfields.size()) { // set the value + versionfields.at(0)->set_child_text( valstr ); + } else { + // make a new field + Xml::Node &n = pNode->add( Xml::Node("CacheVersion", NULL) ); + n.set_child_text( valstr ); + } + free( valstr ); + } else { + debugError("No root node\n"); + } +} + +bool +Util::XMLSerialize::write( std::string strMemberName, + long long value ) + +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %d\n", + strMemberName.c_str(), value ); + + std::vector tokens; + tokenize( strMemberName, tokens, "/" ); + + if ( tokens.size() == 0 ) { + debugWarning( "token size is 0\n" ); + return false; + } + + Xml::Node* pNode = m_doc.get_root_node(); + if(pNode) { + pNode = getNodePath( pNode, tokens ); + if(pNode) { + // element to be added + Xml::Node& n = pNode->add( Xml::Node(tokens[tokens.size() - 1].c_str(), NULL) ); + char* valstr; + asprintf( &valstr, "%lld", value ); + n.set_child_text( valstr ); + free( valstr ); + } else { + return false; + } + } else { + return false; + } + return true; +} + +bool +Util::XMLSerialize::write( std::string strMemberName, + std::string str) +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %s\n", + strMemberName.c_str(), str.c_str() ); + + std::vector tokens; + tokenize( strMemberName, tokens, "/" ); + + if ( tokens.size() == 0 ) { + debugWarning( "token size is 0\n" ); + return false; + } + + Xml::Node* pNode = m_doc.get_root_node(); + if(pNode) { + pNode = getNodePath( pNode, tokens ); + if(pNode) { + // element to be added + Xml::Node& n = pNode->add( Xml::Node(tokens[tokens.size() - 1].c_str(), NULL) ); + n.set_child_text( str ); + } else { + return false; + } + } else { + return false; + } + return true; + +} + +Util::Xml::Node* +Util::XMLSerialize::getNodePath( Util::Xml::Node* pRootNode, + std::vector& tokens ) +{ + // returns the correct node on which the new element has to be added. + // if the path does not exist, it will be created. + + if ( tokens.size() == 1 ) { + return pRootNode; + } + + unsigned int iTokenIdx = 0; + Xml::Node* pCurNode = pRootNode; + for (bool bFound = false; + ( iTokenIdx < tokens.size() - 1 ); + bFound = false, iTokenIdx++ ) + { + Xml::Node::Children& nodeList = pCurNode->children; + for ( Xml::Node::Children::iterator it = nodeList.begin(); + it != nodeList.end(); + ++it ) + { + Xml::Node* thisNode = &( *it ); + if ( thisNode->name.compare(tokens[iTokenIdx]) == 0 ) { + pCurNode = thisNode; + bFound = true; + break; + } + } + if ( !bFound ) { + break; + } + } + + for ( unsigned int i = iTokenIdx; i < tokens.size() - 1; i++, iTokenIdx++ ) { + Xml::Node& n = pCurNode->add( Xml::Node(tokens[iTokenIdx].c_str(), NULL) ); + pCurNode = &n; + } + return pCurNode; +} + +/***********************************/ + +Util::XMLDeserialize::XMLDeserialize( std::string fileName ) + : IODeserialize() + , m_filepath( fileName ) + , m_verboseLevel( DEBUG_LEVEL_NORMAL ) +{ + setDebugLevel(DEBUG_LEVEL_NORMAL); + try { +// m_parser.set_substitute_entities(); //We just want the text to + //be resolved/unescaped + //automatically. + m_doc.load_from_file(m_filepath); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLDeserialize::XMLDeserialize( std::string fileName, int verboseLevel ) + : IODeserialize() + , m_filepath( fileName ) + , m_verboseLevel( verboseLevel ) +{ + setDebugLevel(verboseLevel); + try { +// m_parser.set_substitute_entities(); //We just want the text to + //be resolved/unescaped + //automatically. + m_doc.load_from_file(m_filepath); + } catch ( const exception& ex ) { + cout << "Exception caught: " << ex.what(); + } +} + +Util::XMLDeserialize::~XMLDeserialize() +{ +} + +bool +Util::XMLDeserialize::isValid() +{ + return checkVersion(); +} + +bool +Util::XMLDeserialize::checkVersion() +{ + std::string savedVersion; + if (read( "CacheVersion", savedVersion )) { + std::string expectedVersion = CACHE_VERSION; + debugOutput( DEBUG_LEVEL_NORMAL, "Cache version: %s, expected: %s.\n", savedVersion.c_str(), expectedVersion.c_str() ); + if (expectedVersion == savedVersion) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version OK.\n" ); + return true; + } else { + debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version not OK.\n" ); + return false; + } + } else return false; +} + +bool +Util::XMLDeserialize::read( std::string strMemberName, + long long& value ) + +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "lookup %s\n", strMemberName.c_str() ); + + Xml::Node* pNode = m_doc.get_root_node(); + + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "pNode = %s\n", pNode->name.c_str() ); + if(pNode) { + Xml::Nodes nodeSet = pNode->find( strMemberName ); + for ( Xml::Nodes::iterator it = nodeSet.begin(); + it != nodeSet.end(); + ++it ) + { + Xml::Node *n = *it; + if(n && n->has_child_text() ) { + char* tail; + value = strtoll( n->get_child_text().c_str(), + &tail, 0 ); + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %d\n", + strMemberName.c_str(), value ); + return true; + } + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; + } + + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; + } else { + debugError("No root node\n"); + return false; + } +} + +bool +Util::XMLDeserialize::read( std::string strMemberName, + std::string& str ) +{ + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "lookup %s\n", strMemberName.c_str() ); + + Xml::Node* pNode = m_doc.get_root_node(); + + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "pNode = %s\n", pNode->name.c_str() ); + if(pNode) { + Xml::Nodes nodeSet = pNode->find( strMemberName ); + for ( Xml::Nodes::iterator it = nodeSet.begin(); + it != nodeSet.end(); + ++it ) + { + Xml::Node *n = *it; + if(n) { + if(n->has_child_text() ) { + str = n->get_child_text(); + } else { + str = ""; + } + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %s\n", + strMemberName.c_str(), str.c_str() ); + return true; + } + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; + } + + debugWarning( "no such a node %s\n", strMemberName.c_str() ); + return false; + } else { + debugError("No root node\n"); + return false; + } +} + +bool +Util::XMLDeserialize::isExisting( std::string strMemberName ) +{ + Xml::Node* pNode = m_doc.get_root_node(); + if(pNode) { + Xml::Nodes nodeSet = pNode->find( strMemberName ); + return nodeSet.size() > 0; + } else return false; +} + +void +tokenize(const string& str, + vector& tokens, + const string& delimiters) +{ + // Skip delimiters at beginning. + string::size_type lastPos = str.find_first_not_of(delimiters, 0); + // Find first "non-delimiter". + string::size_type pos = str.find_first_of(delimiters, lastPos); + + while (string::npos != pos || string::npos != lastPos) + { + // Found a token, add it to the vector. + tokens.push_back(str.substr(lastPos, pos - lastPos)); + // Skip delimiters. Note the "not_of" + lastPos = str.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = str.find_first_of(delimiters, lastPos); + } +} Index: /unk/libffado/src/libutil/serialize.cpp =================================================================== --- /trunk/libffado/src/libutil/serialize.cpp (revision 864) +++ (revision ) @@ -1,344 +1,0 @@ -/* - * Copyright (C) 2005-2008 by Daniel Wagner - * - * This file is part of FFADO - * FFADO = Free Firewire (pro-)audio drivers for linux - * - * FFADO is based upon FreeBoB. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#include "config.h" // FOR CACHE_VERSION - -#include "serialize.h" - -using namespace std; - - -IMPL_DEBUG_MODULE( Util::XMLSerialize, XMLSerialize, DEBUG_LEVEL_NORMAL ); -IMPL_DEBUG_MODULE( Util::XMLDeserialize, XMLDeserialize, DEBUG_LEVEL_NORMAL ); - -Util::XMLSerialize::XMLSerialize( Glib::ustring fileName ) - : IOSerialize() - , m_filepath( fileName ) - , m_verboseLevel( DEBUG_LEVEL_NORMAL ) -{ - setDebugLevel( DEBUG_LEVEL_NORMAL ); - try { - m_doc.create_root_node( "ffado_cache" ); - writeVersion(); - } catch ( const exception& ex ) { - cout << "Exception caught: " << ex.what(); - } -} - -Util::XMLSerialize::XMLSerialize( Glib::ustring fileName, int verboseLevel ) - : IOSerialize() - , m_filepath( fileName ) - , m_verboseLevel( verboseLevel ) -{ - setDebugLevel(verboseLevel); - try { - m_doc.create_root_node( "ffado_cache" ); - writeVersion(); - } catch ( const exception& ex ) { - cout << "Exception caught: " << ex.what(); - } -} - -Util::XMLSerialize::~XMLSerialize() -{ - try { - m_doc.write_to_file_formatted( m_filepath ); - } catch ( const exception& ex ) { - cout << "Exception caugth: " << ex.what(); - } - -} - -void -Util::XMLSerialize::writeVersion() -{ - xmlpp::Node* pNode = m_doc.get_root_node(); - xmlpp::Element* pElem = pNode->add_child( "CacheVersion" ); - char* valstr; - asprintf( &valstr, "%s", CACHE_VERSION ); - pElem->set_child_text( valstr ); - free( valstr ); -} - -bool -Util::XMLSerialize::write( std::string strMemberName, - long long value ) - -{ - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %d\n", - strMemberName.c_str(), value ); - - vector tokens; - tokenize( strMemberName, tokens, "/" ); - - if ( tokens.size() == 0 ) { - debugWarning( "token size is 0\n" ); - return false; - } - - xmlpp::Node* pNode = m_doc.get_root_node(); - pNode = getNodePath( pNode, tokens ); - - // element to be added - xmlpp::Element* pElem = pNode->add_child( tokens[tokens.size() - 1] ); - char* valstr; - asprintf( &valstr, "%lld", value ); - pElem->set_child_text( valstr ); - free( valstr ); - - return true; -} - -bool -Util::XMLSerialize::write( std::string strMemberName, - Glib::ustring str) -{ - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %s\n", - strMemberName.c_str(), str.c_str() ); - - vector tokens; - tokenize( strMemberName, tokens, "/" ); - - if ( tokens.size() == 0 ) { - debugWarning( "token size is 0\n" ); - return false; - } - - xmlpp::Node* pNode = m_doc.get_root_node(); - pNode = getNodePath( pNode, tokens ); - - // element to be added - xmlpp::Element* pElem = pNode->add_child( tokens[tokens.size() - 1] ); - pElem->set_child_text( str ); - - return true; -} - -xmlpp::Node* -Util::XMLSerialize::getNodePath( xmlpp::Node* pRootNode, - std::vector& tokens ) -{ - // returns the correct node on which the new element has to be added. - // if the path does not exist, it will be created. - - if ( tokens.size() == 1 ) { - return pRootNode; - } - - unsigned int iTokenIdx = 0; - xmlpp::Node* pCurNode = pRootNode; - for (bool bFound = false; - ( iTokenIdx < tokens.size() - 1 ); - bFound = false, iTokenIdx++ ) - { - xmlpp::Node::NodeList nodeList = pCurNode->get_children(); - for ( xmlpp::Node::NodeList::iterator it = nodeList.begin(); - it != nodeList.end(); - ++it ) - { - if ( ( *it )->get_name() == tokens[iTokenIdx] ) { - pCurNode = *it; - bFound = true; - break; - } - } - if ( !bFound ) { - break; - } - } - - for ( unsigned int i = iTokenIdx; i < tokens.size() - 1; i++, iTokenIdx++ ) { - pCurNode = pCurNode->add_child( tokens[iTokenIdx] ); - } - return pCurNode; - -} - -/***********************************/ - -Util::XMLDeserialize::XMLDeserialize( Glib::ustring fileName ) - : IODeserialize() - , m_filepath( fileName ) - , m_verboseLevel( DEBUG_LEVEL_NORMAL ) -{ - setDebugLevel(DEBUG_LEVEL_NORMAL); - try { - m_parser.set_substitute_entities(); //We just want the text to - //be resolved/unescaped - //automatically. - m_parser.parse_file( m_filepath ); - } catch ( const exception& ex ) { - cout << "Exception caught: " << ex.what(); - } -} - -Util::XMLDeserialize::XMLDeserialize( Glib::ustring fileName, int verboseLevel ) - : IODeserialize() - , m_filepath( fileName ) - , m_verboseLevel( verboseLevel ) -{ - setDebugLevel(verboseLevel); - try { - m_parser.set_substitute_entities(); //We just want the text to - //be resolved/unescaped - //automatically. - m_parser.parse_file( m_filepath ); - } catch ( const exception& ex ) { - cout << "Exception caught: " << ex.what(); - } -} - -Util::XMLDeserialize::~XMLDeserialize() -{ -} - -bool -Util::XMLDeserialize::isValid() -{ - return checkVersion(); -} - -bool -Util::XMLDeserialize::checkVersion() -{ - Glib::ustring savedVersion; - if (read( "CacheVersion", savedVersion )) { - Glib::ustring expectedVersion = CACHE_VERSION; - debugOutput( DEBUG_LEVEL_NORMAL, "Cache version: %s, expected: %s.\n", savedVersion.c_str(), expectedVersion.c_str() ); - if (expectedVersion == savedVersion) { - debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version OK.\n" ); - return true; - } else { - debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version not OK.\n" ); - return false; - } - } else return false; -} - -bool -Util::XMLDeserialize::read( std::string strMemberName, - long long& value ) - -{ - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "lookup %s\n", strMemberName.c_str() ); - - xmlpp::Document *pDoc=m_parser.get_document(); - if(!pDoc) { - debugWarning( "no document found\n" ); - return false; - } - xmlpp::Node* pNode = pDoc->get_root_node(); - - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "pNode = %s\n", pNode->get_name().c_str() ); - - xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); - for ( xmlpp::NodeSet::iterator it = nodeSet.begin(); - it != nodeSet.end(); - ++it ) - { - const xmlpp::Element* pElement = - dynamic_cast< const xmlpp::Element* >( *it ); - if ( pElement && pElement->has_child_text() ) { - char* tail; - value = strtoll( pElement->get_child_text()->get_content().c_str(), - &tail, 0 ); - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %d\n", - strMemberName.c_str(), value ); - return true; - } - debugWarning( "no such a node %s\n", strMemberName.c_str() ); - return false; - } - - debugWarning( "no such a node %s\n", strMemberName.c_str() ); - return false; -} - -bool -Util::XMLDeserialize::read( std::string strMemberName, - Glib::ustring& str ) -{ - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "lookup %s\n", strMemberName.c_str() ); - - xmlpp::Document *pDoc=m_parser.get_document(); - if(!pDoc) { - debugWarning( "no document found\n" ); - return false; - } - xmlpp::Node* pNode = pDoc->get_root_node(); - - xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); - for ( xmlpp::NodeSet::iterator it = nodeSet.begin(); - it != nodeSet.end(); - ++it ) - { - const xmlpp::Element* pElement = dynamic_cast< const xmlpp::Element* >( *it ); - if ( pElement ) { - if ( pElement->has_child_text() ) { - str = pElement->get_child_text()->get_content(); - } else { - str = ""; - } - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %s\n", - strMemberName.c_str(), str.c_str() ); - return true; - } - debugWarning( "no such a node %s\n", strMemberName.c_str() ); - return false; - } - - debugWarning( "no such a node %s\n", strMemberName.c_str() ); - return false; -} - -bool -Util::XMLDeserialize::isExisting( std::string strMemberName ) -{ - xmlpp::Document *pDoc=m_parser.get_document(); - if(!pDoc) { - return false; - } - xmlpp::Node* pNode = pDoc->get_root_node(); - xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); - return nodeSet.size() > 0; -} - -void -tokenize(const string& str, - vector& tokens, - const string& delimiters) -{ - // Skip delimiters at beginning. - string::size_type lastPos = str.find_first_not_of(delimiters, 0); - // Find first "non-delimiter". - string::size_type pos = str.find_first_of(delimiters, lastPos); - - while (string::npos != pos || string::npos != lastPos) - { - // Found a token, add it to the vector. - tokens.push_back(str.substr(lastPos, pos - lastPos)); - // Skip delimiters. Note the "not_of" - lastPos = str.find_first_not_of(delimiters, pos); - // Find next "non-delimiter" - pos = str.find_first_of(delimiters, lastPos); - } -} Index: /trunk/libffado/src/genericavc/avc_avdevice.cpp =================================================================== --- /trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 1135) +++ /trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 1154) @@ -754,5 +754,5 @@ bool -AvDevice::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const +AvDevice::serialize( std::string basePath, Util::IOSerialize& ser ) const { bool result; @@ -763,5 +763,5 @@ bool -AvDevice::deserialize( Glib::ustring basePath, Util::IODeserialize& deser ) +AvDevice::deserialize( std::string basePath, Util::IODeserialize& deser ) { bool result; Index: /trunk/libffado/src/genericavc/avc_avdevice.h =================================================================== --- /trunk/libffado/src/genericavc/avc_avdevice.h (revision 864) +++ /trunk/libffado/src/genericavc/avc_avdevice.h (revision 1154) @@ -55,6 +55,6 @@ static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr( configRom )); - virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - virtual bool deserialize( Glib::ustring basePath, Util::IODeserialize& deser ); + virtual bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + virtual bool deserialize( std::string basePath, Util::IODeserialize& deser ); virtual void setVerboseLevel(int l); Index: /trunk/libffado/src/bebob/bebob_functionblock.h =================================================================== --- /trunk/libffado/src/bebob/bebob_functionblock.h (revision 1110) +++ /trunk/libffado/src/bebob/bebob_functionblock.h (revision 1154) @@ -30,4 +30,6 @@ #include "debugmodule/debugmodule.h" + +#include namespace AVC { @@ -77,11 +79,11 @@ AVC::no_of_output_plugs_t getNrOfOutputPlugs() {return m_nrOfOutputPlugs;}; - bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - - static FunctionBlock* deserialize( Glib::ustring basePath, + bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + + static FunctionBlock* deserialize( std::string basePath, Util::IODeserialize& deser, AVC::Unit& unit, AVC::Subunit& subunit ); - bool deserializeUpdate( Glib::ustring basePath, + bool deserializeUpdate( std::string basePath, Util::IODeserialize& deser ); protected: @@ -124,7 +126,7 @@ protected: - virtual bool serializeChild( Glib::ustring basePath, - Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, + Util::IOSerialize& ser ) const; + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& avDevice ); @@ -166,7 +168,7 @@ protected: - virtual bool serializeChild( Glib::ustring basePath, - Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, + Util::IOSerialize& ser ) const; + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& avDevice ); @@ -193,7 +195,7 @@ protected: - virtual bool serializeChild( Glib::ustring basePath, - Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, + Util::IOSerialize& ser ) const; + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& avDevice ); @@ -218,7 +220,7 @@ protected: - virtual bool serializeChild( Glib::ustring basePath, - Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, + Util::IOSerialize& ser ) const; + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& avDevice ); @@ -243,7 +245,7 @@ protected: - virtual bool serializeChild( Glib::ustring basePath, - Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, + Util::IOSerialize& ser ) const; + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& avDevice ); Index: /trunk/libffado/src/bebob/bebob_avdevice.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 1066) +++ /trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 1154) @@ -380,5 +380,5 @@ bool -AvDevice::serialize( Glib::ustring basePath, +AvDevice::serialize( std::string basePath, Util::IOSerialize& ser ) const { @@ -389,5 +389,5 @@ bool -AvDevice::deserialize( Glib::ustring basePath, +AvDevice::deserialize( std::string basePath, Util::IODeserialize& deser ) { @@ -397,8 +397,8 @@ } -Glib::ustring +std::string AvDevice::getCachePath() { - Glib::ustring cachePath; + std::string cachePath; char* pCachePath; @@ -422,5 +422,5 @@ AvDevice::loadFromCache() { - Glib::ustring sDevicePath = getCachePath() + getConfigRom().getGuidString(); + std::string sDevicePath = getCachePath() + getConfigRom().getGuidString(); char* configId; @@ -431,5 +431,5 @@ } - Glib::ustring sFileName = sDevicePath + "/" + configId + ".xml"; + std::string sFileName = sDevicePath + "/" + configId + ".xml"; free( configId ); debugOutput( DEBUG_LEVEL_NORMAL, "filename %s\n", sFileName.c_str() ); Index: /trunk/libffado/src/bebob/bebob_avdevice.h =================================================================== --- /trunk/libffado/src/bebob/bebob_avdevice.h (revision 864) +++ /trunk/libffado/src/bebob/bebob_avdevice.h (revision 1154) @@ -90,6 +90,6 @@ public: - virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - virtual bool deserialize( Glib::ustring basePath, Util::IODeserialize& deser ); + virtual bool serialize( std::string basePath, Util::IOSerialize& ser ) const; + virtual bool deserialize( std::string basePath, Util::IODeserialize& deser ); int getConfigurationIdSampleRate(); @@ -98,5 +98,5 @@ int getConfigurationId(); - Glib::ustring getCachePath(); + std::string getCachePath(); protected: Index: /trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp (revision 1110) +++ /trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp (revision 1154) @@ -339,5 +339,5 @@ bool -BeBoB::SubunitAudio::serializeChild( Glib::ustring basePath, +BeBoB::SubunitAudio::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -362,5 +362,5 @@ bool -BeBoB::SubunitAudio::deserializeChild( Glib::ustring basePath, +BeBoB::SubunitAudio::deserializeChild( std::string basePath, Util::IODeserialize& deser, AVC::Unit& avDevice ) @@ -387,5 +387,5 @@ bool -BeBoB::SubunitAudio::deserializeUpdateChild( Glib::ustring basePath, +BeBoB::SubunitAudio::deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ) { @@ -467,5 +467,5 @@ bool -BeBoB::SubunitMusic::serializeChild( Glib::ustring basePath, +BeBoB::SubunitMusic::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -474,5 +474,5 @@ bool -BeBoB::SubunitMusic::deserializeChild( Glib::ustring basePath, +BeBoB::SubunitMusic::deserializeChild( std::string basePath, Util::IODeserialize& deser, AVC::Unit& avDevice ) @@ -482,5 +482,5 @@ bool -BeBoB::SubunitMusic::deserializeUpdateChild( Glib::ustring basePath, +BeBoB::SubunitMusic::deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ) { Index: /trunk/libffado/src/bebob/bebob_functionblock.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_functionblock.cpp (revision 1110) +++ /trunk/libffado/src/bebob/bebob_functionblock.cpp (revision 1154) @@ -162,5 +162,5 @@ bool -FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const +FunctionBlock::serialize( std::string basePath, Util::IOSerialize& ser ) const { bool result; @@ -178,5 +178,5 @@ FunctionBlock* -FunctionBlock::deserialize( Glib::ustring basePath, +FunctionBlock::deserialize( std::string basePath, Util::IODeserialize& deser, AVC::Unit& unit, @@ -241,5 +241,5 @@ bool -FunctionBlock::deserializeUpdate( Glib::ustring basePath, +FunctionBlock::deserializeUpdate( std::string basePath, Util::IODeserialize& deser ) { @@ -293,5 +293,5 @@ bool -FunctionBlockSelector::serializeChild( Glib::ustring basePath, +FunctionBlockSelector::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -300,5 +300,5 @@ bool -FunctionBlockSelector::deserializeChild( Glib::ustring basePath, +FunctionBlockSelector::deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& unit ) @@ -349,5 +349,5 @@ bool -FunctionBlockFeature::serializeChild( Glib::ustring basePath, +FunctionBlockFeature::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -356,5 +356,5 @@ bool -FunctionBlockFeature::deserializeChild( Glib::ustring basePath, +FunctionBlockFeature::deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& unit ) @@ -452,5 +452,5 @@ bool -FunctionBlockEnhancedMixer::serializeChild( Glib::ustring basePath, +FunctionBlockEnhancedMixer::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -459,5 +459,5 @@ bool -FunctionBlockEnhancedMixer::deserializeChild( Glib::ustring basePath, +FunctionBlockEnhancedMixer::deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& unit ) @@ -508,5 +508,5 @@ bool -FunctionBlockProcessing::serializeChild( Glib::ustring basePath, +FunctionBlockProcessing::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -515,5 +515,5 @@ bool -FunctionBlockProcessing::deserializeChild( Glib::ustring basePath, +FunctionBlockProcessing::deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& unit ) @@ -563,5 +563,5 @@ bool -FunctionBlockCodec::serializeChild( Glib::ustring basePath, +FunctionBlockCodec::serializeChild( std::string basePath, Util::IOSerialize& ser ) const { @@ -570,5 +570,5 @@ bool -FunctionBlockCodec::deserializeChild( Glib::ustring basePath, +FunctionBlockCodec::deserializeChild( std::string basePath, Util::IODeserialize& deser, AvDevice& unit ) Index: /trunk/libffado/src/bebob/bebob_avplug.h =================================================================== --- /trunk/libffado/src/bebob/bebob_avplug.h (revision 864) +++ /trunk/libffado/src/bebob/bebob_avplug.h (revision 1154) @@ -36,6 +36,4 @@ #include "debugmodule/debugmodule.h" - -#include class Ieee1394Service; Index: /trunk/libffado/src/bebob/bebob_avdevice_subunit.h =================================================================== --- /trunk/libffado/src/bebob/bebob_avdevice_subunit.h (revision 1110) +++ /trunk/libffado/src/bebob/bebob_avdevice_subunit.h (revision 1154) @@ -77,10 +77,10 @@ AVC::function_block_special_purpose_t specialPurpose ); - virtual bool serializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, AVC::Unit& unit ); - virtual bool deserializeUpdateChild( Glib::ustring basePath, + virtual bool deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ); @@ -112,10 +112,10 @@ protected: - virtual bool serializeChild( Glib::ustring basePath, + virtual bool serializeChild( std::string basePath, Util::IOSerialize& ser ) const; - virtual bool deserializeChild( Glib::ustring basePath, + virtual bool deserializeChild( std::string basePath, Util::IODeserialize& deser, AVC::Unit& unit ); - virtual bool deserializeUpdateChild( Glib::ustring basePath, + virtual bool deserializeUpdateChild( std::string basePath, Util::IODeserialize& deser ); Index: /trunk/libffado/src/maudio/maudio_avdevice.cpp =================================================================== --- /trunk/libffado/src/maudio/maudio_avdevice.cpp (revision 864) +++ /trunk/libffado/src/maudio/maudio_avdevice.cpp (revision 1154) @@ -31,7 +31,4 @@ #include "debugmodule/debugmodule.h" - -#include -#include #include Index: /trunk/libffado/config.h.in =================================================================== --- /trunk/libffado/config.h.in (revision 1116) +++ /trunk/libffado/config.h.in (revision 1154) @@ -37,4 +37,7 @@ /* Define indicatin availability of lrintf() */ #define HAVE_LRINTF $HAVE_LRINTF + +// serialization +#define SERIALIZE_USE_EXPAT $SERIALIZE_USE_EXPAT // use a RT-safe message buffer for debug output Index: /trunk/libffado/tests/SConscript =================================================================== --- /trunk/libffado/tests/SConscript (revision 1121) +++ /trunk/libffado/tests/SConscript (revision 1154) @@ -32,5 +32,8 @@ if not env.GetOption( "clean" ): env.MergeFlags( env['LIBRAW1394_FLAGS'] ) - env.MergeFlags( env['LIBXML26_FLAGS'] ) + if not env['SERIALIZE_USE_EXPAT']: + env.MergeFlags( env['LIBXML26_FLAGS'] ) + else: + env.PrependUnique( LIBS=["expat"] ) static_env = env.Copy() Index: /trunk/libffado/tests/systemtests/SConscript =================================================================== --- /trunk/libffado/tests/systemtests/SConscript (revision 1148) +++ /trunk/libffado/tests/systemtests/SConscript (revision 1154) @@ -32,5 +32,4 @@ if not env.GetOption( "clean" ): env.MergeFlags( env['LIBRAW1394_FLAGS'] ) - env.MergeFlags( env['LIBXML26_FLAGS'] ) static_env = env.Copy() Index: /trunk/libffado/SConstruct =================================================================== --- /trunk/libffado/SConstruct (revision 1153) +++ /trunk/libffado/SConstruct (revision 1154) @@ -74,4 +74,5 @@ this code.""", False ), BoolOption( "ENABLE_ALL", "Enable/Disable support for all devices.", False ), + BoolOption( "SERIALIZE_USE_EXPAT", "Use libexpat for XML serialization.", False ), BoolOption( "BUILD_TESTS", """\ Build the tests in their directory. As some contain quite some functionality, @@ -162,4 +163,9 @@ log_file = "cache/" + build_base + 'config.log' ) +if env['SERIALIZE_USE_EXPAT']: + env['SERIALIZE_USE_EXPAT']=1 +else: + env['SERIALIZE_USE_EXPAT']=0 + if not env.GetOption('clean'): # @@ -182,4 +188,5 @@ # allpresent = 1; + # for DBUS C++ bindings allpresent &= conf.CheckHeader( "expat.h" ) allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include ' ) @@ -191,7 +198,9 @@ 'libavc1394' : '0.5.3', 'libiec61883' : '1.1.0', - 'libxml++-2.6' : '2.13.0', 'dbus-1' : '1.0', } + if not env['SERIALIZE_USE_EXPAT']: + pkgs['libxml++-2.6'] = '2.13.0' + for pkg in pkgs: name2 = pkg.replace("+","").replace(".","").replace("-","").upper() Index: /trunk/libffado/support/firmware/SConscript =================================================================== --- /trunk/libffado/support/firmware/SConscript (revision 900) +++ /trunk/libffado/support/firmware/SConscript (revision 1154) @@ -33,5 +33,8 @@ env.MergeFlags( env['LIBAVC1394_FLAGS'] ) env.MergeFlags( env['LIBIEC61883_FLAGS'] ) - env.MergeFlags( env['LIBXML26_FLAGS'] ) + if not env['SERIALIZE_USE_EXPAT']: + env.MergeFlags( env['LIBXML26_FLAGS'] ) + else: + env.PrependUnique( LIBS=["expat"] ) static_env = env.Copy() Index: /trunk/libffado/support/dbus/SConscript =================================================================== --- /trunk/libffado/support/dbus/SConscript (revision 864) +++ /trunk/libffado/support/dbus/SConscript (revision 1154) @@ -36,6 +36,8 @@ if not env.GetOption( "clean" ): env.MergeFlags( env["DBUS1_FLAGS"] ) - env.MergeFlags( env['LIBRAW1394_FLAGS'] ) - env.MergeFlags( env['LIBXML26_FLAGS'] ) + if not env['SERIALIZE_USE_EXPAT']: + env.MergeFlags( env['LIBXML26_FLAGS'] ) + else: + env.PrependUnique( LIBS=["expat"] ) env.Xml2Cpp_Proxy('controlclient-glue.h', 'control-interface.xml')