question_python.h 2.4 KB

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