question_python.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_QUESTION_H
  15. #define __PYTHON_QUESTION_H 1
  16. #include <Python.h>
  17. #include <dns/question.h>
  18. namespace isc {
  19. namespace dns {
  20. namespace python {
  21. //
  22. // Declaration of the custom exceptions
  23. // Initialization and addition of these go in the module init at the
  24. // end
  25. //
  26. extern PyObject* po_EmptyQuestion;
  27. extern PyTypeObject question_type;
  28. /// This is a simple shortcut to create a python Question object (in the
  29. /// form of a pointer to PyObject) with minimal exception safety.
  30. /// On success, it returns a valid pointer to PyObject with a reference
  31. /// counter of 1; if something goes wrong it throws an exception (it never
  32. /// returns a NULL pointer).
  33. /// This function is expected to be called within a try block
  34. /// followed by necessary setup for python exception.
  35. PyObject* createQuestionObject(const Question& source);
  36. /// \brief Checks if the given python object is a Question object
  37. ///
  38. /// \exception PyCPPWrapperException if obj is NULL
  39. ///
  40. /// \param obj The object to check the type of
  41. /// \return true if the object is of type Question, false otherwise
  42. bool PyQuestion_Check(PyObject* obj);
  43. /// \brief Returns a reference to the Question object contained within the given
  44. /// Python object.
  45. ///
  46. /// \note The given object MUST be of type Question; this can be checked with
  47. /// either the right call to ParseTuple("O!"), or with PyQuestion_Check()
  48. ///
  49. /// \note This is not a copy; if the Question is needed when the PyObject
  50. /// may be destroyed, the caller must copy it itself.
  51. ///
  52. /// \param question_obj The question object to convert
  53. const Question& PyQuestion_ToQuestion(const PyObject* question_obj);
  54. } // namespace python
  55. } // namespace dns
  56. } // namespace isc
  57. #endif // __PYTHON_QUESTION_H
  58. // Local Variables:
  59. // mode: c++
  60. // End: