apply folding expression and std::optional
This commit is contained in:
parent
4917b18c70
commit
be836b5b48
@ -204,6 +204,7 @@
|
||||
# define _nana_cxx_constexpr_if
|
||||
# define _nana_cxx_folding_expression
|
||||
# define _nana_cxx_nested_namespace_definition
|
||||
# define _nana_std_optional
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -14,7 +14,11 @@
|
||||
#define NANA_WIDGET_CONTENT_MEASURER_INTERFACE_HEADER_INCLUDED
|
||||
|
||||
#include <nana/basic_types.hpp>
|
||||
#include <nana/optional.hpp>
|
||||
#ifdef _nana_std_optional
|
||||
# include <optional>
|
||||
#else
|
||||
# include <nana/optional.hpp>
|
||||
#endif
|
||||
#include <nana/paint/graphics.hpp>
|
||||
|
||||
namespace nana
|
||||
@ -35,7 +39,7 @@ namespace nana
|
||||
* @param limit_width True if limits the width, false if limits the height.
|
||||
* @return the size of content.
|
||||
*/
|
||||
virtual optional<size> measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const = 0;
|
||||
virtual ::std::optional<size> measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const = 0;
|
||||
|
||||
/// Returns the extension to the size of widget from content extent
|
||||
/**
|
||||
|
||||
@ -461,7 +461,7 @@ namespace API
|
||||
* @return if optional has a value, the first size indicates the content extent, the second size indicates the size of
|
||||
* widget by the content extent.
|
||||
*/
|
||||
optional<std::pair<::nana::size, ::nana::size>> content_extent(window wd, unsigned limited_px, bool limit_width);
|
||||
std::optional<std::pair<::nana::size, ::nana::size>> content_extent(window wd, unsigned limited_px, bool limit_width);
|
||||
}//end namespace API
|
||||
|
||||
}//end namespace nana
|
||||
|
||||
@ -34,7 +34,12 @@ namespace nana
|
||||
::std::string get(std::string msgid_utf8, Args&&... args) const
|
||||
{
|
||||
std::vector<std::string> arg_strs;
|
||||
|
||||
#ifdef _nana_cxx_folding_expression
|
||||
(_m_fetch_args(arg_strs, std::forward<Args>(args)),...);
|
||||
#else
|
||||
_m_fetch_args(arg_strs, std::forward<Args>(args)...);
|
||||
#endif
|
||||
|
||||
auto msgstr = _m_get(std::move(msgid_utf8));
|
||||
_m_replace_args(msgstr, &arg_strs);
|
||||
@ -53,25 +58,28 @@ namespace nana
|
||||
std::string _m_get(std::string&& msgid) const;
|
||||
void _m_replace_args(::std::string& str, std::vector<::std::string> * arg_strs) const;
|
||||
|
||||
void _m_fetch_args(std::vector<std::string>&) const; //Termination of _m_fetch_args
|
||||
#ifndef _nana_cxx_folding_expression
|
||||
static void _m_fetch_args(std::vector<std::string>&); //Termination of _m_fetch_args
|
||||
#endif
|
||||
|
||||
void _m_fetch_args(std::vector<std::string>& v, const char* arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, const std::string& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::string& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::string&& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, const wchar_t* arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, const std::wstring& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::wstring& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::wstring&& arg) const;
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const char* arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const std::string& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::string& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::string&& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const wchar_t* arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const std::wstring& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::wstring& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::wstring&& arg);
|
||||
|
||||
template<typename Arg>
|
||||
void _m_fetch_args(std::vector<std::string>& v, Arg&& arg) const
|
||||
static void _m_fetch_args(std::vector<std::string>& v, Arg&& arg)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << arg;
|
||||
v.emplace_back(ss.str());
|
||||
}
|
||||
|
||||
#ifndef _nana_cxx_folding_expression
|
||||
template<typename ...Args>
|
||||
void _m_fetch_args(std::vector<std::string>& v, const char* arg, Args&&... args) const
|
||||
{
|
||||
@ -136,6 +144,7 @@ namespace nana
|
||||
v.emplace_back(ss.str());
|
||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
};//end class internationalization
|
||||
|
||||
class i18n_eval
|
||||
@ -180,7 +189,11 @@ namespace nana
|
||||
i18n_eval(std::string msgid_utf8, Args&&... args)
|
||||
: msgid_(std::move(msgid_utf8))
|
||||
{
|
||||
#ifdef _nana_cxx_folding_expression
|
||||
(_m_fetch_args(std::forward<Args>(args)), ...);
|
||||
#else
|
||||
_m_fetch_args(std::forward<Args>(args)...);
|
||||
#endif
|
||||
}
|
||||
|
||||
i18n_eval(const i18n_eval&);
|
||||
@ -193,6 +206,7 @@ namespace nana
|
||||
|
||||
std::string operator()() const;
|
||||
private:
|
||||
#ifndef _nana_cxx_folding_expression
|
||||
void _m_fetch_args(){} //Termination of _m_fetch_args
|
||||
|
||||
template<typename Arg, typename ...Args>
|
||||
@ -201,6 +215,7 @@ namespace nana
|
||||
_m_add_args(std::forward<Arg>(arg));
|
||||
_m_fetch_args(std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Arg>
|
||||
void _m_add_args(Arg&& arg)
|
||||
|
||||
@ -15,8 +15,11 @@
|
||||
#ifndef NANA_STD_OPTIONAL_HEADER_INCLUDED
|
||||
#define NANA_STD_OPTIONAL_HEADER_INCLUDED
|
||||
|
||||
#include <stdexcept>
|
||||
#include <nana/c++defines.hpp>
|
||||
|
||||
#ifndef _nana_std_optional
|
||||
#include <stdexcept>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
@ -361,4 +364,9 @@ namespace nana
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
using nana::optional;
|
||||
}
|
||||
#endif //_nana_std_optional
|
||||
#endif
|
||||
|
||||
@ -1450,7 +1450,7 @@ namespace API
|
||||
restrict::wd_manager().set_safe_place(reinterpret_cast<basic_window*>(wd), std::move(fn));
|
||||
}
|
||||
|
||||
optional<std::pair<size, size>> content_extent(window wd, unsigned limited_px, bool limit_width)
|
||||
std::optional<std::pair<size, size>> content_extent(window wd, unsigned limited_px, bool limit_width)
|
||||
{
|
||||
auto iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
|
||||
@ -27,7 +27,7 @@ namespace nana{ namespace drawerbase
|
||||
: trigger_{ t }
|
||||
{}
|
||||
|
||||
optional<size> measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override
|
||||
std::optional<size> measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override
|
||||
{
|
||||
//Button doesn't provide a support of vfit and hfit
|
||||
if (limit_pixels)
|
||||
|
||||
@ -90,7 +90,7 @@ namespace nana
|
||||
: drw_{ drwimpl }
|
||||
{}
|
||||
|
||||
optional<size> measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override
|
||||
std::optional<size> measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override
|
||||
{
|
||||
//Combox doesn't provide a support of vfit and hfit
|
||||
if (limit_pixels)
|
||||
|
||||
@ -653,7 +653,7 @@ namespace nana
|
||||
: impl_{ impl }
|
||||
{}
|
||||
|
||||
optional<size> measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const override
|
||||
std::optional<size> measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const override
|
||||
{
|
||||
//Label now doesn't support to measure content with a specified height.
|
||||
if (graph && ((0 == limit_pixels) || limit_width))
|
||||
|
||||
@ -74,7 +74,7 @@ namespace nana
|
||||
: impl_{impl}
|
||||
{}
|
||||
|
||||
optional<size> measure(graph_reference /*graph*/, unsigned limit_pixels, bool /*limit_width*/) const override
|
||||
std::optional<size> measure(graph_reference /*graph*/, unsigned limit_pixels, bool /*limit_width*/) const override
|
||||
{
|
||||
//Picture doesn't provide a support of vfit and hfit
|
||||
if (!limit_pixels)
|
||||
|
||||
@ -414,45 +414,47 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>&) const
|
||||
#ifndef _nana_cxx_folding_expression
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>&)
|
||||
{}
|
||||
#endif
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const char* arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const char* arg)
|
||||
{
|
||||
v.emplace_back(arg);
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const std::string& arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const std::string& arg)
|
||||
{
|
||||
v.emplace_back(arg);
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::string& arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::string& arg)
|
||||
{
|
||||
v.emplace_back(arg);
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::string&& arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::string&& arg)
|
||||
{
|
||||
v.emplace_back(std::move(arg));
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const wchar_t* arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const wchar_t* arg)
|
||||
{
|
||||
v.emplace_back(to_utf8(arg));
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const std::wstring& arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, const std::wstring& arg)
|
||||
{
|
||||
v.emplace_back(to_utf8(arg));
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::wstring& arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::wstring& arg)
|
||||
{
|
||||
v.emplace_back(to_utf8(arg));
|
||||
}
|
||||
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::wstring&& arg) const
|
||||
void internationalization::_m_fetch_args(std::vector<std::string>& v, std::wstring&& arg)
|
||||
{
|
||||
v.emplace_back(to_utf8(arg));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user