1061d255b5967b91f3790e5d993dc153c7f7d75e
[iec.git] / src / type3_AndroidCloud / anbox-master / external / android-emugl / host / tools / emugen / EntryPoint.h
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef __EntryPoint__H__
17 #define __EntryPoint__H__
18
19 #include <string>
20 #include <vector>
21 #include <stdio.h>
22
23 #include "Var.h"
24
25 //---------------------------------------------------
26
27 typedef std::vector<Var> VarsArray;
28
29 class EntryPoint {
30 public:
31     EntryPoint();
32     virtual ~EntryPoint();
33     bool parse(unsigned int lc, const std::string & str);
34     void reset(); // reset the class to empty;
35     void print(FILE *fp = stdout, bool newline = true,
36                const std::string & name_suffix = std::string(""),
37                const std::string & name_prefix = std::string(""),
38                const std::string & ctx_param = std::string("")) const;
39     const std::string & name() const { return m_name; }
40     VarsArray & vars() { return m_vars; }
41     Var & retval() { return m_retval; }
42     Var * var(const std::string & name);
43     bool hasPointers();
44     bool unsupported() const { return m_unsupported; }
45     void setUnsupported(bool state) { m_unsupported = state; }
46     bool customDecoder() { return m_customDecoder; }
47     void setCustomDecoder(bool state) { m_customDecoder = state; }
48     bool notApi() const { return m_notApi; }
49     void setNotApi(bool state) { m_notApi = state; }
50     bool flushOnEncode() const { return m_flushOnEncode; }
51     void setFlushOnEncode(bool state) { m_flushOnEncode = state; }
52     int setAttribute(const std::string &line, size_t lc);
53
54 private:
55     enum { PR_RETVAL = 0, PR_NAME, PR_VARS, PR_DONE } prState;
56     std::string m_name;
57     Var m_retval;
58     VarsArray m_vars;
59     bool m_unsupported;
60     bool m_customDecoder;
61     bool m_notApi;
62     bool m_flushOnEncode;
63
64     void err(unsigned int lc, const char *msg) {
65         fprintf(stderr, "line %d: %s\n", lc, msg);
66     }
67 };
68
69
70 #endif