Orcus
global.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 */
7
8#ifndef INCLUDED_ORCUS_GLOBAL_HPP
9#define INCLUDED_ORCUS_GLOBAL_HPP
10
11#include "types.hpp"
12#include "env.hpp"
13
14#include <memory>
15#include <functional>
16
17#define ORCUS_ASCII(literal) literal, sizeof(literal)-1
18#define ORCUS_N_ELEMENTS(name) sizeof(name)/sizeof(name[0])
19
20namespace orcus {
21
22class tokens;
23
24ORCUS_DLLPUBLIC void print_element(xmlns_id_t ns, xml_token_t name);
25
29ORCUS_DLLPUBLIC void print_attrs(const tokens& tokens, const xml_attrs_t& attrs);
30
43ORCUS_DLLPUBLIC date_time_t to_date_time(const pstring& str);
44
49template<typename T>
50struct map_object_deleter : public ::std::unary_function<typename T::value_type, void>
51{
52 void operator() (typename T::value_type& v)
53 {
54 delete v.second;
55 }
56};
57
58template<typename T, typename ...Args>
59std::unique_ptr<T> make_unique(Args&& ...args)
60{
61 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
62}
63
64}
65
66#endif
67/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: global.hpp:51