#ifndef __JLANG__JSTDTOOLKIT__ #define __JLANG__JSTDTOOLKIT__ #include "JLang/JSTDTypes.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Get value in map. * * The value in the map at the given key is returned if present else the default value. * * \param map map * \param key key * \param value default value * \return value */ template inline const JValue_t& getValue(const std::map& map, const JKey_t& key, const JValue_t& value) { typename std::map::const_iterator i = map.find(key); if (i != map.end()) return i->second; else return value; } /** * Put end marker. * * The end marker is put at the end but within the capacity of the given vector whilst its size is maintained. * * \param buffer buffer * \param value end marker */ template inline void putEndMarker(std::vector& buffer, const JElement_t& value) { if (buffer.capacity() <= buffer.size()) { buffer.reserve(buffer.size() + 1); } *(buffer.end()) = value; } } #endif