PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Lib/pike/std_string.i

#
Swig | 63 lines | 38 code | 16 blank | 9 comment | 0 complexity | e2752c609355537ab67d66b2acf44ff0 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * See the LICENSE file for information on copyright, usage and redistribution
  3. * of SWIG, and the README file for authors - http://www.swig.org/release.html.
  4. *
  5. * std_string.i
  6. *
  7. * SWIG typemaps for std::string
  8. * ----------------------------------------------------------------------------- */
  9. %{
  10. #include <string>
  11. %}
  12. namespace std {
  13. %naturalvar string;
  14. class string;
  15. /* Overloading check */
  16. %typemap(typecheck) string = char *;
  17. %typemap(typecheck) const string & = char *;
  18. %typemap(in, pikedesc="tStr") string {
  19. if ($input.type != T_STRING)
  20. Pike_error("Bad argument: Expected a string.\n");
  21. $1 = std::string(STR0($input.u.string));
  22. }
  23. %typemap(in, pikedesc="tStr") const string & (std::string temp) {
  24. if ($input.type != T_STRING)
  25. Pike_error("Bad argument: Expected a string.\n");
  26. temp = std::string(STR0($input.u.string));
  27. $1 = &temp;
  28. }
  29. %typemap(out, pikedesc="tStr") string "push_text($1.c_str());";
  30. %typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());";
  31. %typemap(directorin) string, const string &, string & "$1_name.c_str()";
  32. %typemap(directorin) string *, const string * "$1_name->c_str()";
  33. %typemap(directorout) string {
  34. if ($input.type == T_STRING)
  35. $result = std::string(STR0($input.u.string));
  36. else
  37. throw Swig::DirectorTypeMismatchException("string expected");
  38. }
  39. %typemap(directorout) const string & (std::string temp) {
  40. if ($input.type == T_STRING) {
  41. temp = std::string(STR0($input.u.string));
  42. $result = &temp;
  43. } else {
  44. throw Swig::DirectorTypeMismatchException("string expected");
  45. }
  46. }
  47. }