Skip to content

Instantly share code, notes, and snippets.

@camden-smallwood-zz
Created November 10, 2017 08:52
Show Gist options
  • Save camden-smallwood-zz/75ea9f446e9eb1a451cb664f8a57f08c to your computer and use it in GitHub Desktop.
Save camden-smallwood-zz/75ea9f446e9eb1a451cb664f8a57f08c to your computer and use it in GitHub Desktop.
#include "FieldDefinition.hpp"
namespace Definitions
{
FieldDefinition::FieldDefinition(const FieldType &type) :
FieldDefinition(type, "")
{
}
FieldDefinition::FieldDefinition(const FieldType &type, const long length) :
FieldDefinition(type, FieldType::Skip, "", length)
{
}
FieldDefinition::FieldDefinition(const FieldType &type, const std::string &name) :
FieldDefinition(type, FieldType::Skip, name, 1)
{
}
FieldDefinition::FieldDefinition(const FieldType &type, const std::string &name, const EnumDefinition *enumDef) :
FieldDefinition(type, FieldType::Skip, name, 1, enumDef)
{
}
FieldDefinition::FieldDefinition(const FieldType &type, const std::string &name, const StructDefinition *structDef) :
FieldDefinition(type, FieldType::Skip, name, 1, structDef)
{
}
FieldDefinition::FieldDefinition(const FieldType &type, const FieldType &arrayType, const std::string &name, const long length) :
Type(type), ArrayType(arrayType), Name(name), Length(length)
{
}
FieldDefinition::FieldDefinition(const FieldType &type, const FieldType &arrayType, const std::string &name, const long length, const EnumDefinition *enumDef) :
Type(type), ArrayType(arrayType), Name(name), Length(length), Enum(enumDef)
{
}
FieldDefinition::FieldDefinition(const FieldType &type, const FieldType &arrayType, const std::string &name, const long length, const StructDefinition *structDef) :
Type(type), ArrayType(arrayType), Name(name), Length(length), Struct(structDef)
{
}
}
#pragma once
#include <string>
namespace Definitions
{
enum class FieldType
{
Tag,
String,
LongString,
StringID,
CharInteger,
ShortInteger,
LongInteger,
Int64Integer,
ByteInteger,
WordInteger,
DwordInteger,
QwordInteger,
CharEnum,
ShortEnum,
LongEnum,
ByteFlags,
WordFlags,
LongFlags,
Angle,
Point2D,
Rectangle2D,
RgbColor,
ArgbColor,
Real,
RealFraction,
RealPoint2D,
RealPoint3D,
RealVector2D,
RealVector3D,
RealQuaternion,
RealEulerAngles2D,
RealEulerAngles3D,
RealPlane2D,
RealPlane3D,
RealRgbColor,
RealArgbColor,
RealHsvColor,
RealAhsvColor,
ShortIntegerBounds,
AngleBounds,
RealBounds,
FractionBounds,
TagReference,
Block,
CharBlockIndex,
ShortBlockIndex,
LongBlockIndex,
Data,
PageableResource,
Pad,
Skip,
Explanation,
Custom,
Struct,
Array
};
struct EnumDefinition;
struct StructDefinition;
struct FieldDefinition
{
const FieldType Type;
const FieldType ArrayType;
const std::string Name;
const long Length;
union
{
const EnumDefinition *Enum;
const StructDefinition *Struct;
};
FieldDefinition(const FieldType &type);
FieldDefinition(const FieldType &type, const long length);
FieldDefinition(const FieldType &type, const std::string &name);
FieldDefinition(const FieldType &type, const std::string &name, const EnumDefinition *enumDef);
FieldDefinition(const FieldType &type, const std::string &name, const StructDefinition *structDef);
FieldDefinition(const FieldType &type, const FieldType &arrayType, const std::string &name, const long length);
FieldDefinition(const FieldType &type, const FieldType &arrayType, const std::string &name, const long length, const EnumDefinition *enumDef);
FieldDefinition(const FieldType &type, const FieldType &arrayType, const std::string &name, const long length, const StructDefinition *structDef);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment