• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 
17 #pragma once
18 
19 #include <iostream>
20 
21 #include "fields/packet_field.h"
22 
23 class TypeDef {
24  public:
TypeDef(std::string name)25   TypeDef(std::string name) : name_(name) {}
26 
TypeDef(std::string name,int size)27   TypeDef(std::string name, int size) : name_(name), size_(size) {}
28 
29   virtual ~TypeDef() = default;
30 
GetTypeName()31   std::string GetTypeName() const {
32     return name_;
33   }
34 
35   enum class Type {
36     INVALID,
37     ENUM,
38     CHECKSUM,
39     CUSTOM,
40     PACKET,
41     STRUCT,
42   };
43 
44   virtual Type GetDefinitionType() const = 0;
45 
46   virtual PacketField* GetNewField(const std::string& name, ParseLocation loc) const = 0;
47 
48   const std::string name_;
49   const int size_{-1};
50 };
51