Panda3D
 All Classes Functions Variables Enumerations
animationConvert.cxx
1 // Filename: animationConvert.cxx
2 // Created by: drose (21Jan03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "animationConvert.h"
16 
17 #include "string_utils.h"
18 #include "pnotify.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: format_animation_convert
22 // Description: Returns the string corresponding to this method.
23 ////////////////////////////////////////////////////////////////////
24 string
25 format_animation_convert(AnimationConvert convert) {
26  switch (convert) {
27  case AC_invalid:
28  return "invalid";
29 
30  case AC_none:
31  return "none";
32 
33  case AC_pose:
34  return "pose";
35 
36  case AC_flip:
37  return "flip";
38 
39  case AC_strobe:
40  return "strobe";
41 
42  case AC_model:
43  return "model";
44 
45  case AC_chan:
46  return "chan";
47 
48  case AC_both:
49  return "both";
50  }
51  nout << "**unexpected AnimationConvert value: (" << (int)convert << ")**";
52  return "**";
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: AnimationConvert output operator
57 // Description:
58 ////////////////////////////////////////////////////////////////////
59 ostream &
60 operator << (ostream &out, AnimationConvert convert) {
61  return out << format_animation_convert(convert);
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: string_animation_convert
66 // Description: Converts from a string, as might be input by the
67 // user, to one of the known AnimationConvert types.
68 // Returns AC_invalid if the string is unknown.
69 ////////////////////////////////////////////////////////////////////
70 AnimationConvert
71 string_animation_convert(const string &str) {
72  if (cmp_nocase(str, "none") == 0) {
73  return AC_none;
74 
75  } else if (cmp_nocase(str, "pose") == 0) {
76  return AC_pose;
77 
78  } else if (cmp_nocase(str, "flip") == 0) {
79  return AC_flip;
80 
81  } else if (cmp_nocase(str, "strobe") == 0) {
82  return AC_strobe;
83 
84  } else if (cmp_nocase(str, "model") == 0) {
85  return AC_model;
86 
87  } else if (cmp_nocase(str, "chan") == 0) {
88  return AC_chan;
89 
90  } else if (cmp_nocase(str, "both") == 0) {
91  return AC_both;
92 
93  } else {
94  return AC_invalid;
95  }
96 }