Panda3D
 All Classes Functions Variables Enumerations
pathStore.cxx
00001 // Filename: pathStore.cxx
00002 // Created by:  drose (10Feb03)
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 "pathStore.h"
00016 
00017 #include "string_utils.h"
00018 #include "pnotify.h"
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: format_path_store
00022 //  Description: Returns the string corresponding to this method.
00023 ////////////////////////////////////////////////////////////////////
00024 string
00025 format_path_store(PathStore store) {
00026   switch (store) {
00027   case PS_invalid:
00028     return "invalid";
00029 
00030   case PS_relative:
00031     return "relative";
00032 
00033   case PS_absolute:
00034     return "absolute";
00035 
00036   case PS_rel_abs:
00037     return "rel_abs";
00038 
00039   case PS_strip:
00040     return "strip";
00041 
00042   case PS_keep:
00043     return "keep";
00044   }
00045   nout << "**unexpected PathStore value: (" << (int)store << ")**";
00046   return "**";
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: PathStore output operator
00051 //  Description:
00052 ////////////////////////////////////////////////////////////////////
00053 ostream &
00054 operator << (ostream &out, PathStore store) {
00055   return out << format_path_store(store);
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: string_path_store
00060 //  Description: Stores from a string, as might be input by the
00061 //               user, to one of the known PathStore types.
00062 //               Returns PS_invalid if the string is unknown.
00063 ////////////////////////////////////////////////////////////////////
00064 PathStore
00065 string_path_store(const string &str) {
00066   if (cmp_nocase(str, "relative") == 0 || 
00067       cmp_nocase(str, "rel") == 0) {
00068     return PS_relative;
00069 
00070   } else if (cmp_nocase(str, "absolute") == 0 ||
00071              cmp_nocase(str, "abs") == 0) {
00072     return PS_absolute;
00073 
00074   } else if (cmp_nocase_uh(str, "rel_abs") == 0) {
00075     return PS_rel_abs;
00076 
00077   } else if (cmp_nocase(str, "strip") == 0) {
00078     return PS_strip;
00079 
00080   } else if (cmp_nocase(str, "keep") == 0) {
00081     return PS_keep;
00082 
00083   } else {
00084     return PS_invalid;
00085   }
00086 }
 All Classes Functions Variables Enumerations