Panda3D
 All Classes Functions Variables Enumerations
autoTextureScale.cxx
1 // Filename: autoTextureScale.cxx
2 // Created by: drose (28Nov11)
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 "autoTextureScale.h"
16 #include "string_utils.h"
17 #include "config_util.h"
18 
19 ostream &
20 operator << (ostream &out, AutoTextureScale ats) {
21  switch (ats) {
22  case ATS_none:
23  return out << "none";
24 
25  case ATS_down:
26  return out << "down";
27 
28  case ATS_up:
29  return out << "up";
30 
31  case ATS_pad:
32  return out << "pad";
33 
34  case ATS_unspecified:
35  return out << "unspecified";
36  }
37 
38  return out << "**invalid AutoTextureScale (" << (int)ats << ")**";
39 }
40 
41 istream &
42 operator >> (istream &in, AutoTextureScale &ats) {
43  string word;
44  in >> word;
45 
46  if (cmp_nocase(word, "none") == 0 ||
47  cmp_nocase(word, "0") == 0 ||
48  cmp_nocase(word, "#f") == 0 ||
49  (!word.empty() && tolower(word[0]) == 'f')) {
50  ats = ATS_none;
51 
52  } else if (cmp_nocase(word, "down") == 0 ||
53  cmp_nocase(word, "1") == 0 ||
54  cmp_nocase(word, "#t") == 0 ||
55  (!word.empty() && tolower(word[0]) == 't')) {
56  ats = ATS_down;
57 
58  } else if (cmp_nocase(word, "up") == 0) {
59  ats = ATS_up;
60 
61  } else if (cmp_nocase(word, "pad") == 0) {
62  ats = ATS_pad;
63 
64  } else {
65  util_cat->error() << "Invalid AutoTextureScale value: " << word << "\n";
66  ats = ATS_none;
67  }
68 
69  return in;
70 }