]> git.mxchange.org Git - simgear.git/blob - simgear/nasal/cppbind/from_nasal.hxx
First working version of DOM like Canvas event handling
[simgear.git] / simgear / nasal / cppbind / from_nasal.hxx
1 ///@file
2 /// Conversion functions to convert Nasal types to C++ types
3 ///
4 // Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Library General Public
8 // License as published by the Free Software Foundation; either
9 // version 2 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Library General Public License for more details.
15 //
16 // You should have received a copy of the GNU Library General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
19
20 #ifndef SG_FROM_NASAL_HXX_
21 #define SG_FROM_NASAL_HXX_
22
23 #include "from_nasal_detail.hxx"
24
25 namespace nasal
26 {
27
28   /**
29    * Convert a Nasal type to any supported C++ type.
30    *
31    * @param c   Active Nasal context
32    * @param ref Nasal object to be converted
33    * @tparam T  Target type of conversion
34    *
35    * @throws bad_nasal_cast if conversion is not possible
36    *
37    * @note  Every type which should be supported needs a function with the
38    *        following signature declared:
39    *
40    *        Type from_nasal_helper(naContext, naRef, Type*)
41    */
42   template<class T>
43   T from_nasal(naContext c, naRef ref)
44   {
45     return from_nasal_helper(c, ref, static_cast<T*>(0));
46   }
47
48 } // namespace nasal
49
50 #endif /* SG_FROM_NASAL_HXX_ */