Panda3D
interrogateFunction.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 interrogateFunction.cxx
10  * @author drose
11  * @date 2000-08-01
12  */
13 
14 #include "interrogateFunction.h"
15 #include "indexRemapper.h"
16 #include "interrogate_datafile.h"
17 #include "interrogateDatabase.h"
18 
19 /**
20  *
21  */
22 InterrogateFunction::
23 InterrogateFunction(InterrogateModuleDef *def) :
25 {
26  _flags = 0;
27  _class = 0;
28  _instances = nullptr;
29 }
30 
31 /**
32  *
33  */
34 InterrogateFunction::
35 InterrogateFunction(const InterrogateFunction &copy) {
36  (*this) = copy;
37 }
38 
39 /**
40  *
41  */
42 void InterrogateFunction::
43 operator = (const InterrogateFunction &copy) {
44  InterrogateComponent::operator = (copy);
45  _flags = copy._flags;
46  _scoped_name = copy._scoped_name;
47  _comment = copy._comment;
48  _prototype = copy._prototype;
49  _class = copy._class;
50  _c_wrappers = copy._c_wrappers;
51  _python_wrappers = copy._python_wrappers;
52 
53  _instances = copy._instances;
54  _expression = copy._expression;
55 }
56 
57 /**
58  * Formats the InterrogateFunction data for output to a data file.
59  */
61 output(std::ostream &out) const {
63  out << _flags << " "
64  << _class << " ";
65  idf_output_string(out, _scoped_name);
66  idf_output_vector(out, _c_wrappers);
67  idf_output_vector(out, _python_wrappers);
68  idf_output_string(out, _comment, '\n');
69  idf_output_string(out, _prototype, '\n');
70 }
71 
72 /**
73  * Reads the data file as previously formatted by output().
74  */
76 input(std::istream &in) {
78  in >> _flags >> _class;
79  idf_input_string(in, _scoped_name);
80  idf_input_vector(in, _c_wrappers);
81  idf_input_vector(in, _python_wrappers);
82  idf_input_string(in, _comment);
83  idf_input_string(in, _prototype);
84 }
85 
86 /**
87  * Remaps all internal index numbers according to the indicated map. This
88  * called from InterrogateDatabase::remap_indices().
89  */
92  _class = remap.map_from(_class);
93  Wrappers::iterator wi;
94  for (wi = _c_wrappers.begin(); wi != _c_wrappers.end(); ++wi) {
95  (*wi) = remap.map_from(*wi);
96  }
97  for (wi = _python_wrappers.begin(); wi != _python_wrappers.end(); ++wi) {
98  (*wi) = remap.map_from(*wi);
99  }
100 }
void idf_input_vector(std::istream &in, std::vector< Element > &vec)
Reads the given vector from the input file, as previously written by output_string().
This class manages a mapping of integers to integers.
Definition: indexRemapper.h:29
void idf_output_string(ostream &out, const string &str, char whitespace)
Writes the indicated string to the output file.
void input(std::istream &in)
Reads the data file as previously formatted by output().
void idf_input_string(istream &in, string &str)
Reads the given string from the input file, as previously written by output_string().
void output(std::ostream &out) const
Formats the component for output to a data file.
void remap_indices(const IndexRemapper &remap)
Remaps all internal index numbers according to the indicated map.
An internal representation of a function.
The base class for things that are part of the interrogate database.
void input(std::istream &in)
Reads the data file as previously formatted by output().
void output(std::ostream &out) const
Formats the InterrogateFunction data for output to a data file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void idf_output_vector(std::ostream &out, const std::vector< Element > &vec)
Writes the indicated vector to the output file.
int map_from(int from) const
Returns the integer that the given 'from' integer had been set to map to, or the same integer if noth...