Panda3D

animationConvert.cxx

00001 // Filename: animationConvert.cxx
00002 // Created by:  drose (21Jan03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "animationConvert.h"
00016 
00017 #include "string_utils.h"
00018 #include "pnotify.h"
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: format_animation_convert
00022 //  Description: Returns the string corresponding to this method.
00023 ////////////////////////////////////////////////////////////////////
00024 string
00025 format_animation_convert(AnimationConvert convert) {
00026   switch (convert) {
00027   case AC_invalid:
00028     return "invalid";
00029 
00030   case AC_none:
00031     return "none";
00032 
00033   case AC_pose:
00034     return "pose";
00035 
00036   case AC_flip:
00037     return "flip";
00038 
00039   case AC_strobe:
00040     return "strobe";
00041 
00042   case AC_model:
00043     return "model";
00044 
00045   case AC_chan:
00046     return "chan";
00047 
00048   case AC_both:
00049     return "both";
00050   }
00051   nout << "**unexpected AnimationConvert value: (" << (int)convert << ")**";
00052   return "**";
00053 }
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //     Function: AnimationConvert output operator
00057 //  Description:
00058 ////////////////////////////////////////////////////////////////////
00059 ostream &
00060 operator << (ostream &out, AnimationConvert convert) {
00061   return out << format_animation_convert(convert);
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: string_animation_convert
00066 //  Description: Converts from a string, as might be input by the
00067 //               user, to one of the known AnimationConvert types.
00068 //               Returns AC_invalid if the string is unknown.
00069 ////////////////////////////////////////////////////////////////////
00070 AnimationConvert
00071 string_animation_convert(const string &str) {
00072   if (cmp_nocase(str, "none") == 0) {
00073     return AC_none;
00074 
00075   } else if (cmp_nocase(str, "pose") == 0) {
00076     return AC_pose;
00077 
00078   } else if (cmp_nocase(str, "flip") == 0) {
00079     return AC_flip;
00080 
00081   } else if (cmp_nocase(str, "strobe") == 0) {
00082     return AC_strobe;
00083 
00084   } else if (cmp_nocase(str, "model") == 0) {
00085     return AC_model;
00086 
00087   } else if (cmp_nocase(str, "chan") == 0) {
00088     return AC_chan;
00089 
00090   } else if (cmp_nocase(str, "both") == 0) {
00091     return AC_both;
00092 
00093   } else {
00094     return AC_invalid;
00095   }
00096 }
 All Classes Functions Variables Enumerations