Main MRPT website > C++ reference
MRPT logo
Classes | Namespaces | Defines | Functions

stl_extensions.h File Reference

#include <mrpt/utils/CSerializable.h>
#include <mrpt/utils/CStream.h>
#include <mrpt/utils/metaprogramming.h>
#include <set>
#include <map>
#include <list>
#include <cctype>
#include <mrpt/utils/circular_buffer.h>
#include <mrpt/utils/list_searchable.h>
#include <mrpt/utils/bimap.h>
#include <mrpt/utils/map_as_vector.h>
#include <mrpt/utils/traits_map.h>
Include dependency graph for stl_extensions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mrpt::utils::ci_less
 A case-insensitive comparator struct for usage within STL containers, eg: map<string,string,ci_less> More...
struct  mrpt::utils::ci_less::nocase_compare

Namespaces

namespace  mrpt
 

This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.


namespace  mrpt::utils
 

Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.


Defines

#define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(CONTAINER)
#define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER(CONTAINER)
#define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER(CONTAINER)

Functions

 mrpt::utils::MRPTSTL_SERIALIZABLE_SEQ_CONTAINER (std::vector) MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(std
 Template method to serialize a STL pair.
template<class T1 , class T2 >
CStream & mrpt::utils::operator>> (CStream &in, std::pair< T1, T2 > &obj)
 Template method to deserialize a STL pair.
template<class T , class CONTAINER >
size_t mrpt::utils::find_in_vector (const T &value, const CONTAINER &vect)
 Returns the index of the value "T" in the container "vect" (std::vector,std::deque,etc), or string::npos if not found.
template<class T >
std::list< T >::iterator mrpt::utils::erase_return_next (std::list< T > &cont, typename std::list< T >::iterator &it)
 Calls the standard "erase" method of a STL container, but also returns an iterator to the next element in the container (or end if none)
template<class K , class V >
std::map< K, V >::iterator mrpt::utils::erase_return_next (std::map< K, V > &cont, typename std::map< K, V >::iterator &it)
template<class K , class V >
std::multimap< K, V >::iterator mrpt::utils::erase_return_next (std::multimap< K, V > &cont, typename std::multimap< K, V >::iterator &it)
template<class T >
std::set< T >::iterator mrpt::utils::erase_return_next (std::set< T > &cont, typename std::set< T >::iterator &it)
template<class T >
std::vector< T >::iterator mrpt::utils::erase_return_next (std::vector< T > &cont, typename std::vector< T >::iterator &it)
template<typename T >
std::string mrpt::utils::sprintf_vector (const char *fmt, const std::vector< T > &V)
 Generates a string for a vector in the format [A,B,C,...] to std::cout, and the fmt string for each vector element.
template<typename Derived >
std::string mrpt::utils::sprintf_vector (const char *fmt, const Eigen::MatrixBase< Derived > &V)
template<typename T >
void mrpt::utils::printf_vector (const char *fmt, const std::vector< T > &V)
 Prints a vector in the format [A,B,C,...] to std::cout, and the fmt string for each vector element.

Define Documentation

#define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER (   CONTAINER )

Definition at line 85 of file stl_extensions.h.

#define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER (   CONTAINER )
Value:
/** Template method to serialize a sequential STL container  */ \
                        template <class T,class _Ax> \
                        CStream& operator << (CStream& out, const CONTAINER<T,_Ax> &obj) \
                        { \
                                out << string(#CONTAINER) << TTypeName<T>::get(); \
                                out << static_cast<uint32_t>(obj.size()); \
                                for_each( obj.begin(), obj.end(), ObjectWriteToStream(&out) ); \
                                return out; \
                        } \
                        /** Template method to deserialize a sequential STL container */ \
                        template <class T,class _Ax>  \
                        CStream& operator >> (CStream& in, CONTAINER<T,_Ax> &obj) \
                        { \
                                obj.clear(); \
                                string pref,stored_T; \
                                in >> pref; \
                                if (pref!=#CONTAINER) THROW_EXCEPTION(format("Error: serialized container %s<%s>'s preambles is wrong: '%s'",#CONTAINER,TTypeName<T>::get().c_str(),pref.c_str() )) \
                                in >> stored_T; \
                                if (stored_T != TTypeName<T>::get() ) THROW_EXCEPTION(format("Error: serialized container %s< %s != %s >",#CONTAINER,stored_T.c_str(),TTypeName<T>::get().c_str() )) \
                                uint32_t n; \
                                in >> n; \
                                obj.resize(n); \
                                for_each( obj.begin(), obj.end(), ObjectReadFromStream(&in) ); \
                                return in; \
                        }

Definition at line 57 of file stl_extensions.h.

#define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER (   CONTAINER )
Value:
/** Template method to serialize an associative STL container  */ \
                        template <class K,class _Pr,class _Alloc> \
                        CStream& operator << (CStream& out, const CONTAINER<K,_Pr,_Alloc> &obj) \
                        { \
                                out << string(#CONTAINER) << TTypeName<K>::get(); \
                                out << static_cast<uint32_t>(obj.size()); \
                                for (typename CONTAINER<K,_Pr,_Alloc>::const_iterator it=obj.begin();it!=obj.end();++it) \
                                        out << *it; \
                                return out; \
                        } \
                        /** Template method to deserialize an associative STL container */ \
                        template <class K,class _Pr,class _Alloc>  \
                        CStream& operator >> (CStream& in, CONTAINER<K,_Pr,_Alloc> &obj) \
                        { \
                                obj.clear(); \
                                string pref,stored_K; \
                                in >> pref; \
                                if (pref!=#CONTAINER) THROW_EXCEPTION(format("Error: serialized container %s<%s>'s preamble is wrong: '%s'",#CONTAINER, TTypeName<K>::get().c_str(),pref.c_str())) \
                                in >> stored_K; \
                                if (stored_K != TTypeName<K>::get()) THROW_EXCEPTION(format("Error: serialized container %s key type %s != %s",#CONTAINER,stored_K.c_str(), TTypeName<K>::get().c_str())) \
                                uint32_t n; \
                                in >> n; \
                                for (uint32_t i=0;i<n;i++) \
                                { \
                                        K       key_obj; \
                                        in >> key_obj; \
                                        obj.insert(key_obj); \
                                } \
                                return in; \
                        }

Referenced by mrpt::utils::MRPTSTL_SERIALIZABLE_SEQ_CONTAINER().




Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:30:30 UTC 2011