pykd/pykd/udtutils.h
2017-11-08 17:33:17 +04:00

66 lines
1.8 KiB
C++

#pragma once
///////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <vector>
///////////////////////////////////////////////////////////////////////////////////
namespace pykd {
///////////////////////////////////////////////////////////////////////////////////
class TypeInfo;
typedef boost::shared_ptr<TypeInfo> TypeInfoPtr;
///////////////////////////////////////////////////////////////////////////////////
namespace UdtUtils {
///////////////////////////////////////////////////////////////////////////////////
struct Field {
Field( ULONG offset, const std::string &name, TypeInfoPtr type )
: m_offset(offset), m_name(name), m_type(type)
{}
bool operator ==(const std::string &name) const {
return m_name == name;
}
ULONG m_offset;
std::string m_name;
TypeInfoPtr m_type;
};
///////////////////////////////////////////////////////////////////////////////////
class FieldCollection : public std::vector< Field > {
typedef std::vector< Field > Base;
public:
FieldCollection(const std::string &baseTypeName) : m_baseTypeName(baseTypeName)
{}
const Field &lookup(ULONG index) const;
const Field &lookup(const std::string &name) const;
private:
std::string m_baseTypeName;
};
///////////////////////////////////////////////////////////////////////////////////
ULONG getFiledOffsetRecirsive(TypeInfoPtr typeInfo, const std::string &fieldName);
///////////////////////////////////////////////////////////////////////////////////
} // namespace UdtUtils
///////////////////////////////////////////////////////////////////////////////////
} // namespace pykd
///////////////////////////////////////////////////////////////////////////////////