ICG 2
Electric Boogaloo
StructMember.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include "DataTypeInator.hpp"
6 
11 struct StructMember {
12 
13 public:
14 
15  enum StorageClass {
17  STATIC
18  };
19 
23  StructMember( std::string memberName, std::string typeSpecName, int address, StorageClass storage = NORMAL);
24  ~StructMember();
25 
31  std::string toString() const;
32 
39  void * getAddressOfMember (void * structAddress = NULL) const;
40 
45  inline bool operator< (const StructMember& other) const {
46  return (memberAddress < other.memberAddress);
47  }
48 
49 
50  /* ==================================================================== */
51  /* Trivial getters/setters */
52  /* ==================================================================== */
53 
59  inline std::string getName() const { return name; }
60 
66  inline std::string getTypeSpecName() const { return typeSpecName; }
67 
73  inline std::shared_ptr<const DataType> getSubType() const { return subType; }
74 
80  inline void setSubType(std::shared_ptr<const DataType> type) { subType = type; }
81 
87  inline StorageClass getStorageClass () const { return storage; }
88 
89  private:
90  std::string name;
91  std::string typeSpecName;
92  long memberAddress;
93  StorageClass storage;
94  std::shared_ptr<const DataType> subType;
95 };
Definition: AllocInfo.hpp:22
Represent a normal or static member of a struct.
Definition: StructMember.hpp:11
~StructMember()
Definition: StructMember.cpp:13
void * getAddressOfMember(void *structAddress=NULL) const
Get the address of this member given the base address of a struct containing it.
Definition: StructMember.cpp:29
std::string getName() const
Get the name of this struct member.
Definition: StructMember.hpp:59
std::string getTypeSpecName() const
Get the type name of this struct member.
Definition: StructMember.hpp:66
void setSubType(std::shared_ptr< const DataType > type)
Set the SubType of this member.
Definition: StructMember.hpp:80
bool operator<(const StructMember &other) const
Enable sorting by offset.
Definition: StructMember.hpp:45
std::shared_ptr< const DataType > getSubType() const
Get the type of this member.
Definition: StructMember.hpp:73
std::string toString() const
toString
Definition: StructMember.cpp:15
@ STATIC
Definition: StructMember.hpp:17
@ NORMAL
Definition: StructMember.hpp:16
StorageClass getStorageClass() const
Get the storage class of this member.
Definition: StructMember.hpp:87
StructMember(std::string memberName, std::string typeSpecName, int address, StorageClass storage=NORMAL)
Definition: StructMember.cpp:9