示例#1
0
shared_ptr<const XdmfAttributeCenter>
XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperties)
{
  InitTypes();
  std::map<std::string, std::string>::const_iterator center =
    itemProperties.find("Center");
  if(center == itemProperties.end()) {
    XdmfError::message(XdmfError::FATAL, 
                       "'Center' not found in itemProperties in "
                       "XdmfAttributeCenter::New");
  }

  const std::string & centerVal = ConvertToUpper(center->second);

  std::map<std::string, shared_ptr<const XdmfAttributeCenter>(*)()>::const_iterator returnType = mAttributeCenterDefinitions.find(centerVal);

  if (returnType == mAttributeCenterDefinitions.end()) {
    XdmfError::message(XdmfError::FATAL,
                       "Center not of 'Grid','Cell','Face','Edge','Node' "
                       "in XdmfAttributeCenter::New");
  }
  else {
    return (*(returnType->second))();
  }

  XdmfError::message(XdmfError::FATAL, 
                     "Center not of 'Grid','Cell','Face','Edge','Node' "
                     "in XdmfAttributeCenter::New");

  // unreachable
  return shared_ptr<const XdmfAttributeCenter>();
}
示例#2
0
shared_ptr<const XdmfTopologyType>
XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
{
  InitTypes();

  std::map<std::string, std::string>::const_iterator type =
    itemProperties.find("Type");
  if(type == itemProperties.end()) {
    type = itemProperties.find("TopologyType");
  }
  if(type == itemProperties.end()) {
    XdmfError::message(XdmfError::FATAL,
                       "Neither 'Type' nor 'TopologyType' found in "
                       "itemProperties in XdmfTopologyType::New");
  }
  std::string typeVal = ConvertToUpper(type->second);

  std::map<std::string, std::string>::const_iterator nodesPerElement =
    itemProperties.find("NodesPerElement");

  std::map<std::string, shared_ptr<const XdmfTopologyType>(*)()>::const_iterator returnType
    = mTopologyDefinitions.find(typeVal);

  if (returnType == mTopologyDefinitions.end()) {
    if(typeVal.compare("POLYLINE") == 0) {
      if(nodesPerElement != itemProperties.end()) {
        return Polyline(atoi(nodesPerElement->second.c_str()));
      }
      XdmfError::message(XdmfError::FATAL,
                         "'NodesPerElement' not in itemProperties and type "
                         "'POLYLINE' selected in XdmfTopologyType::New");
    }
    else if(typeVal.compare("POLYGON") == 0) {
      if(nodesPerElement != itemProperties.end()) {
        return Polygon(atoi(nodesPerElement->second.c_str()));
      }
      XdmfError::message(XdmfError::FATAL,
                         "'NodesPerElement' not in itemProperties and type "
                         "'POLYGON' selected in XdmfTopologyType::New");
    }
    else {
      XdmfError::message(XdmfError::FATAL,
                         "Invalid Type selected in XdmfTopologyType::New");

    }
  }
  else {
    return (*(returnType->second))();
  }

  XdmfError::message(XdmfError::FATAL,
                     "Invalid Type selected in XdmfTopologyType::New");

  // unreachable
  return shared_ptr<const XdmfTopologyType>();
}
示例#3
0
int main(int argc, char* argv[])
{
    std::shared_ptr<Process> wow = ProcessTools::Open(_T("Wow.exe"), 20173, true);
    if (!wow)
        return 1;

    std::vector<GameObjectProperty> props = wow->ReadArray<GameObjectProperty>(PROPERTY_DATA - 0x400000, MAX_PROPERTY_INDEX);
    std::string propertyNames[MAX_PROPERTY_INDEX];
    for (std::uint32_t i = 0; i < props.size(); ++i)
        propertyNames[i] = wow->Read<std::string>(props[i].Name);

    std::vector<GameObjectPropertyInfo> typeData = wow->ReadArray<GameObjectPropertyInfo>(GO_TYPE_DATA - 0x400000, MAX_GAMEOBJECT_TYPE);

    InitTypes();

    Structure templateUnion;
    templateUnion.SetName("GameObjectTemplateData");

    for (std::uint32_t i = 0; i < typeData.size(); ++i)
    {
        Structure typeStructure;
        typeStructure.SetComment(std::to_string(i) + " " + TCEnumName[i]);
        typeStructure.SetValueCommentPadding(40);

        std::uint32_t propCount = std::min<std::uint32_t>(MAX_GAMEOBJECT_DATA, typeData[i].Count);
        std::vector<std::uint32_t> propIndexes = wow->ReadArray<std::uint32_t>(typeData[i].List, propCount);
        for (std::size_t j = 0; j < propIndexes.size(); ++j)
        {
            std::string name = propertyNames[propIndexes[j]];
            GameObjectPropertyTypeInfo* type = wow->Read<GameObjectPropertyTypeInfo*>(typeData[i].TypeInfo + j);
            typeStructure.AddMember(Structure::Member(j, "uint32", FixName(name),
                static_cast<std::ostringstream&>(std::ostringstream() << j << " " << name << ", "
                    << FormatType(wow, props[propIndexes[j]].TypeIndex, wow->Read<GameObjectPropertyTypeInfo>(type))).str()));
        }

        templateUnion.AddMember(Structure::Member(i,
            static_cast<std::ostringstream&>(std::ostringstream() << SourceOutput<Structure>(std::make_unique<CppStruct>(true), typeStructure, 4)).str(), FixName(wow->Read<std::string>(typeData[i].TypeName)), ""));
    }

    Structure raw;
    raw.AddMember(Structure::Member(0, "uint32", "data[MAX_GAMEOBJECT_DATA]", ""));

    templateUnion.AddMember(Structure::Member(MAX_GAMEOBJECT_TYPE,
        static_cast<std::ostringstream&>(std::ostringstream() << SourceOutput<Structure>(std::make_unique<CppStruct>(true), raw, 4)).str(), "raw", ""));

    std::ofstream structure("GameObjectTemplate.h");
    structure << SourceOutput<Structure>(std::make_unique<CppUnion>(false), templateUnion, 0);
    return 0;
}
示例#4
0
Runtime::Runtime() :
    context_(llvm::getGlobalContext()) {
    InitTypes();
    InitFunctions();
}