add stub definitions to pass compilation
This commit is contained in:
parent
545d9ea82b
commit
6e4883bcf1
2 changed files with 157 additions and 5 deletions
88
src/lib/format-string.cpp
Normal file
88
src/lib/format-string.cpp
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
FormatString - string template formatting based on boost::format
|
||||||
|
|
||||||
|
Copyright (C) Lumiera.org
|
||||||
|
2011, Hermann Vosseler <Ichthyostega@web.de>
|
||||||
|
|
||||||
|
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) any later version.
|
||||||
|
|
||||||
|
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, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
* *****************************************************/
|
||||||
|
|
||||||
|
/** @file format-string.cpp
|
||||||
|
** Implementation for printf-style formatting, based on boost::format.
|
||||||
|
** This file holds the generic implementation of our format frontend,
|
||||||
|
** which actually just invokes boost::format. The corresponding header
|
||||||
|
** format-string.hpp contains some template functions and classes,
|
||||||
|
** which select an appropriate wrapper to pass the calls down.
|
||||||
|
** Here, we define explicit specialisations for the frontend to invoke,
|
||||||
|
** which in turn just pass on the given argument value to the embedded
|
||||||
|
** boost::format object, which in turn integrates the formatted result
|
||||||
|
** into an embedded string stream.
|
||||||
|
**
|
||||||
|
** To avoid exposing boost::format in the frontend header, we use an
|
||||||
|
** opaque buffer of appropriate size to piggyback the formatter object.
|
||||||
|
** @warning unfortunately this requires a hard coded buffer size constant
|
||||||
|
** in the front-end, which we define there manually, based on
|
||||||
|
** the current implementation layout found in the boost libraries.
|
||||||
|
** If Boost eventually changes the implementation, the assertion
|
||||||
|
** in our constructor will trigger.
|
||||||
|
**
|
||||||
|
** @see FormatString_test
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "lib/error.hpp"
|
||||||
|
#include "lib/format-string.hpp"
|
||||||
|
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace util {
|
||||||
|
|
||||||
|
namespace { // implementation details...
|
||||||
|
|
||||||
|
|
||||||
|
}//(End) implementation details
|
||||||
|
|
||||||
|
|
||||||
|
/** */
|
||||||
|
_Fmt::_Fmt (string formatString)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED ("create the embedded boost::format object");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** */
|
||||||
|
_Fmt::operator string() const
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED ("forward to the embedded boost::format object");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, _Fmt const& fmt)
|
||||||
|
{
|
||||||
|
return os << string(fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace util
|
||||||
|
|
@ -79,7 +79,7 @@ namespace util {
|
||||||
|
|
||||||
namespace { // helpers to pick a suitable specialisation....
|
namespace { // helpers to pick a suitable specialisation....
|
||||||
|
|
||||||
const size_t FORMATTER_SIZE = 100;
|
enum{ FORMATTER_SIZE = 100 };
|
||||||
|
|
||||||
}//(End) guards/helpers
|
}//(End) guards/helpers
|
||||||
|
|
||||||
|
|
@ -94,14 +94,21 @@ namespace util {
|
||||||
{
|
{
|
||||||
char formatter_[FORMATTER_SIZE];
|
char formatter_[FORMATTER_SIZE];
|
||||||
|
|
||||||
|
template<typename VAL, class SEL =void>
|
||||||
|
struct Param;
|
||||||
|
|
||||||
|
template<typename VAL, class SEL>
|
||||||
|
friend struct Param;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_Fmt (string formatString);
|
_Fmt (string formatString);
|
||||||
|
|
||||||
operator string() const;
|
operator string() const;
|
||||||
|
|
||||||
template<typename TY>
|
template<typename VAL>
|
||||||
_Fmt&
|
_Fmt&
|
||||||
operator% (TY const&);
|
operator% (VAL const&);
|
||||||
|
|
||||||
|
|
||||||
friend std::ostream&
|
friend std::ostream&
|
||||||
|
|
@ -121,6 +128,63 @@ namespace util {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* == forwarding into the implementation == */
|
||||||
|
|
||||||
|
template<typename VAL>
|
||||||
|
inline _Fmt&
|
||||||
|
_Fmt::operator% (VAL const& val)
|
||||||
|
{
|
||||||
|
Param<VAL>::push (val);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename VAL, class SEL>
|
||||||
|
struct _Fmt::Param
|
||||||
|
{
|
||||||
|
static void
|
||||||
|
push (VAL const&)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED ("get type string");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator== (_Fmt const& left, _Fmt const& right)
|
||||||
|
{
|
||||||
|
return string(left) == string(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator== (_Fmt const& fmt, string const& str)
|
||||||
|
{
|
||||||
|
return string(fmt) == str;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator== (_Fmt const& fmt, const char * const cString)
|
||||||
|
{
|
||||||
|
return string(fmt) == string(cString);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator== (string const& str, _Fmt const& fmt)
|
||||||
|
{
|
||||||
|
return fmt == str;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator== (const char * const cString, _Fmt const& fmt)
|
||||||
|
{
|
||||||
|
return fmt == cString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
|
||||||
#endif /*UTIL_FORMAT_STRING_H*/
|
#endif /*UTIL_FORMAT_STRING_H*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue