adding ignore rules, finished container support

This commit is contained in:
Shane Grant
2013-06-14 14:36:54 -07:00
parent b50e0d6b2c
commit 156704dfe0
5 changed files with 143 additions and 3 deletions

21
.gitignore vendored Normal file
View File

@@ -0,0 +1,21 @@
# Compiled Object files
*.slo
*.lo
*.o
# Compiled Dynamic libraries
*.so
*.dylib
# Compiled Static libraries
*.lai
*.la
*.a
out.txt
ptr.txt
test
test.txt
unittests
boost_serialize
arr.txt

View File

@@ -16,7 +16,7 @@ namespace cereal
ar & i;
}
//! Loading for std::deque all other types to binary
//! Loading for std::deque to binary
template <class T, class A>
void load( BinaryInputArchive & ar, std::deque<T, A> & deque )
{

View File

@@ -6,7 +6,7 @@
namespace cereal
{
//! Saving for std::list all other types to binary
//! Saving for std::list to binary
template <class T, class A>
void save( BinaryOutputArchive & ar, std::list<T, A> const & list )
{
@@ -16,7 +16,7 @@ namespace cereal
ar & i;
}
//! Loading for std::list all other types to binary
//! Loading for std::list to binary
template <class T, class A>
void load( BinaryInputArchive & ar, std::list<T, A> & list )
{

75
binary_archive/queue.hpp Normal file
View File

@@ -0,0 +1,75 @@
#ifndef CEREAL_BINARY_ARCHIVE_QUEUE_HPP_
#define CEREAL_BINARY_ARCHIVE_QUEUE_HPP_
#include <cereal/binary_archive/binary_archive.hpp>
#include <queue>
namespace cereal
{
namespace queue_detail
{
//! Allows access to the protected container in queue
template <class T, class C>
C const & container( std::queue<T, C> const & queue )
{
struct H : public std::queue<T, C>
{
static C const & get( std::queue<T, C> const & q )
{
return q.*(&H::c);
}
};
return H::get( queue );
}
//! Allows access to the protected container in priority queue
template <class T, class C, class Comp>
C const & container( std::priority_queue<T, C, Comp> const & priority_queue )
{
struct H : public std::priority_queue<T, C, Comp>
{
static C const & get( std::priority_queue<T, C, Comp> const & pq )
{
return pq.*(&H::c);
}
};
return H::get( priority_queue );
}
}
//! Saving for std::queue to binary
template <class T, class C>
void save( BinaryOutputArchive & ar, std::queue<T, C> const & queue )
{
ar & queue_detail::container( queue );
}
//! Loading for std::queue to binary
template <class T, class C>
void load( BinaryInputArchive & ar, std::queue<T, C> & queue )
{
C container;
ar & container;
queue = std::queue<T, C>( std::move( container ) );
}
//! Saving for std::priority_queue to binary
template <class T, class C, class Comp>
void save( BinaryOutputArchive & ar, std::priority_queue<T, C, Comp> const & priority_queue )
{
ar & queue_detail::container( priority_queue );
}
//! Loading for std::priority_queue to binary
template <class T, class C, class Comp>
void load( BinaryInputArchive & ar, std::priority_queue<T, C, Comp> & priority_queue )
{
C container;
ar & container;
priority_queue = std::priority_queue<T, C, Comp>( std::move( container ) );
}
} // namespace cereal
#endif // CEREAL_BINARY_ARCHIVE_QUEUE_HPP_

44
binary_archive/stack.hpp Normal file
View File

@@ -0,0 +1,44 @@
#ifndef CEREAL_BINARY_ARCHIVE_STACK_HPP_
#define CEREAL_BINARY_ARCHIVE_STACK_HPP_
#include <cereal/binary_archive/binary_archive.hpp>
#include <stack>
namespace cereal
{
namespace stack_detail
{
//! Allows access to the protected container in stack
template <class T, class C>
C const & container( std::stack<T, C> const & stack )
{
struct H : public std::stack<T, C>
{
static C const & get( std::stack<T, C> const & s )
{
return s.*(&H::c);
}
};
return H::get( stack );
}
}
//! Saving for std::stack to binary
template <class T, class C>
void save( BinaryOutputArchive & ar, std::stack<T, C> const & stack )
{
ar & stack_detail::container( stack );
}
//! Loading for std::stack to binary
template <class T, class C>
void load( BinaryInputArchive & ar, std::stack<T, C> & stack )
{
C container;
ar & container;
stack = std::stack<T, C>( std::move( container ) );
}
} // namespace cereal
#endif // CEREAL_BINARY_ARCHIVE_STACK_HPP_