Panda3D

Loading...
Searching...
No Matches
pathStore.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pathStore.cxx
10 * @author drose
11 * @date 2003-02-10
12 */
13
14#include "pathStore.h"
15
16#include "string_utils.h"
17#include "pnotify.h"
18
19/**
20 * Returns the string corresponding to this method.
21 */
22std::string
23 format_path_store(PathStore store) {
24 switch (store) {
25 case PS_invalid:
26 return "invalid";
27
28 case PS_relative:
29 return "relative";
30
31 case PS_absolute:
32 return "absolute";
33
34 case PS_rel_abs:
35 return "rel_abs";
36
37 case PS_strip:
38 return "strip";
39
40 case PS_keep:
41 return "keep";
42 }
43 nout << "**unexpected PathStore value: (" << (int)store << ")**";
44 return "**";
45}
46
47/**
48 *
49 */
50std::ostream &
51operator << (std::ostream &out, PathStore store) {
52 return out << format_path_store(store);
53}
54
55/**
56 * Stores from a string, as might be input by the user, to one of the known
57 * PathStore types. Returns PS_invalid if the string is unknown.
58 */
59 PathStore
60 string_path_store(const std::string &str) {
61 if (cmp_nocase(str, "relative") == 0 ||
62 cmp_nocase(str, "rel") == 0) {
63 return PS_relative;
64
65 } else if (cmp_nocase(str, "absolute") == 0 ||
66 cmp_nocase(str, "abs") == 0) {
67 return PS_absolute;
68
69 } else if (cmp_nocase_uh(str, "rel_abs") == 0) {
70 return PS_rel_abs;
71
72 } else if (cmp_nocase(str, "strip") == 0) {
73 return PS_strip;
74
75 } else if (cmp_nocase(str, "keep") == 0) {
76 return PS_keep;
77
78 } else {
79 return PS_invalid;
80 }
81}
string_path_store
PathStore string_path_store(const std::string &str)
Stores from a string, as might be input by the user, to one of the known PathStore types.
Definition pathStore.cxx:60
format_path_store
std::string format_path_store(PathStore store)
Returns the string corresponding to this method.
Definition pathStore.cxx:23
pathStore.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PathStore
PathStore
This enumerated type lists the methods by which a filename path might be mangled before storing in a ...
Definition pathStore.h:23
pnotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
string_utils.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.