blob: aa3824123f9d4719a8427158bec92504480eeb2a [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompson47eecfc2013-07-07 22:56:46 -07002/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Jeff Thompson571f3522013-07-07 22:39:31 -070011 */
12
13#ifndef NDN_COMMON_HPP
14#define NDN_COMMON_HPP
15
Alexander Afanasyev766cea72014-04-24 19:16:42 -070016#include "ndn-cxx-config.hpp"
Alexander Afanasyevd409d592014-01-28 18:36:38 -080017#include <stdint.h>
18// TODO: Is stddef.h portable?
19#include <stddef.h>
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080020#include <unistd.h>
21
22// Standard headers to precompile
Alexander Afanasyevd409d592014-01-28 18:36:38 -080023
Jeff Thompson51dd5fd2013-07-10 19:27:18 -070024#include <vector>
Alexander Afanasyev19508852014-01-29 01:01:51 -080025#include <list>
26#include <set>
27#include <algorithm>
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080028#include <map>
29#include <sstream>
30#include <fstream>
31#include <exception>
32#include <map>
33
34// Other useful headers to precompile
35#include <boost/lexical_cast.hpp>
36#include <boost/asio.hpp>
37#include <boost/date_time/posix_time/posix_time.hpp>
Alexander Afanasyev233750e2014-02-16 00:50:07 -080038#include <boost/utility.hpp>
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080039
40#include <boost/iostreams/detail/ios.hpp>
41#include <boost/iostreams/categories.hpp>
42#include <boost/iostreams/stream.hpp>
Jeff Thompson571f3522013-07-07 22:39:31 -070043
Steve DiBenedettoc145d492014-03-11 16:35:45 -060044#if defined(__GNUC__) || defined(__clang__)
45#define DEPRECATED(func) func __attribute__ ((deprecated))
46#elif defined(_MSC_VER)
47#define DEPRECATED(func) __declspec(deprecated) func
48#else
49#pragma message("DEPRECATED not implemented")
50#define DEPRECATED(func) func
51#endif
52
Alexander Afanasyev766cea72014-04-24 19:16:42 -070053#ifdef NDN_CXX_HAVE_CXX11
Alexander Afanasyev472fa022014-01-07 13:30:49 -080054
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -070055#if defined(__GNUC__)
56# if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
Alexander Afanasyev766cea72014-04-24 19:16:42 -070057# error "NDN-CXX library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -070058# endif // !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
59#endif // defined(__GNUC__)
60
61#if defined(__clang__) && __cplusplus < 201103L
Alexander Afanasyev766cea72014-04-24 19:16:42 -070062# error "NDN-CXX library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -070063#endif // defined(__clang__) && (__cplusplus < 201103L)
64
Alexander Afanasyev472fa022014-01-07 13:30:49 -080065
Jeff Thompson571f3522013-07-07 22:39:31 -070066#include <memory>
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080067#include <functional>
Alexander Afanasyev19508852014-01-29 01:01:51 -080068
69namespace ndn {
70
71namespace ptr_lib = std;
Alexander Afanasyev8460afb2014-02-15 20:31:42 -080072namespace func_lib = std;
73
Alexander Afanasyev19508852014-01-29 01:01:51 -080074using std::shared_ptr;
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -070075using std::weak_ptr;
Alexander Afanasyev19508852014-01-29 01:01:51 -080076using std::make_shared;
77using std::enable_shared_from_this;
78
Alexander Afanasyev15151312014-02-16 00:53:51 -080079using std::static_pointer_cast;
80using std::dynamic_pointer_cast;
81using std::const_pointer_cast;
82
Alexander Afanasyev19508852014-01-29 01:01:51 -080083using std::function;
84using std::bind;
85using std::placeholders; // _1, _2, ..
86
87} // namespace ndn
88
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080089
Alexander Afanasyevd409d592014-01-28 18:36:38 -080090#else
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080091
Jeff Thompson571f3522013-07-07 22:39:31 -070092#include <boost/shared_ptr.hpp>
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -070093#include <boost/weak_ptr.hpp>
Alexander Afanasyevb790d952014-01-24 12:07:53 -080094#include <boost/enable_shared_from_this.hpp>
Jeff Thompson571f3522013-07-07 22:39:31 -070095#include <boost/make_shared.hpp>
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080096
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080097#include <boost/function.hpp>
98#include <boost/bind.hpp>
Alexander Afanasyev19508852014-01-29 01:01:51 -080099
100namespace ndn {
101
102namespace ptr_lib = boost;
103namespace func_lib = boost;
104
105using boost::shared_ptr;
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -0700106using boost::weak_ptr;
Alexander Afanasyev19508852014-01-29 01:01:51 -0800107using boost::make_shared;
108using boost::enable_shared_from_this;
109
Alexander Afanasyev15151312014-02-16 00:53:51 -0800110using boost::static_pointer_cast;
111using boost::dynamic_pointer_cast;
112using boost::const_pointer_cast;
113
Alexander Afanasyev19508852014-01-29 01:01:51 -0800114using boost::function;
115using boost::bind;
116
117} // namespace ndn
Alexander Afanasyev0541cf42014-01-02 19:10:37 -0800118
Alexander Afanasyev766cea72014-04-24 19:16:42 -0700119#endif // NDN_CXX_HAVE_CXX11
Jeff Thompsona28eed82013-08-22 16:21:10 -0700120
Jeff Thompson51dd5fd2013-07-10 19:27:18 -0700121namespace ndn {
Jeff Thompson9a8e82f2013-10-17 14:13:43 -0700122
Alexander Afanasyev233750e2014-02-16 00:50:07 -0800123using boost::noncopyable;
Alexander Afanasyev19508852014-01-29 01:01:51 -0800124
Jeff Thompson51dd5fd2013-07-10 19:27:18 -0700125}
126
Alexander Afanasyev809805d2014-02-17 17:20:33 -0800127#include "util/time.hpp"
128
Jeff Thompson571f3522013-07-07 22:39:31 -0700129#endif