rrset_python.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __PYTHON_RRSET_H
  15. #define __PYTHON_RRSET_H 1
  16. #include <Python.h>
  17. #include <dns/rrset.h>
  18. #include <util/python/pycppwrapper_util.h>
  19. namespace isc {
  20. namespace dns {
  21. namespace python {
  22. //
  23. // Declaration of the custom exceptions
  24. // Initialization and addition of these go in the module init at the
  25. // end
  26. //
  27. extern PyObject* po_EmptyRRset;
  28. extern PyTypeObject rrset_type;
  29. /// This is a simple shortcut to create a python RRset object (in the
  30. /// form of a pointer to PyObject) with minimal exception safety.
  31. /// On success, it returns a valid pointer to PyObject with a reference
  32. /// counter of 1; if something goes wrong it throws an exception (it never
  33. /// returns a NULL pointer).
  34. /// This function is expected to be called within a try block
  35. /// followed by necessary setup for python exception.
  36. PyObject* createRRsetObject(const RRset& source);
  37. /// \brief Checks if the given python object is a RRset object
  38. ///
  39. /// \exception PyCPPWrapperException if obj is NULL
  40. ///
  41. /// \param obj The object to check the type of
  42. /// \return true if the object is of type RRset, false otherwise
  43. bool PyRRset_Check(PyObject* obj);
  44. /// \brief Returns a reference to the RRset object contained within the given
  45. /// Python object.
  46. ///
  47. /// \note The given object MUST be of type RRset; this can be checked with
  48. /// either the right call to ParseTuple("O!"), or with PyRRset_Check()
  49. ///
  50. /// \note This is not a copy; if the RRset is needed when the PyObject
  51. /// may be destroyed, the caller must copy it itself.
  52. ///
  53. /// \param rrset_obj The rrset object to convert
  54. RRset& PyRRset_ToRRset(PyObject* rrset_obj);
  55. /// \brief Returns the shared_ptr of the RRset object contained within the
  56. /// given Python object.
  57. ///
  58. /// \note The given object MUST be of type RRset; this can be checked with
  59. /// either the right call to ParseTuple("O!"), or with PyRRset_Check()
  60. ///
  61. /// \param rrset_obj The rrset object to convert
  62. RRsetPtr PyRRset_ToRRsetPtr(PyObject* rrset_obj);
  63. } // namespace python
  64. } // namespace dns
  65. } // namespace isc
  66. #endif // __PYTHON_RRSET_H
  67. // Local Variables:
  68. // mode: c++
  69. // End: