24 #ifdef USE_ANGELSCRIPT 
   26 #include <angelscript.h> 
   28 #include "scriptdictionary/scriptdictionary.h" 
   29 #include "scriptarray/scriptarray.h" 
   30 #include "scriptbuilder/scriptbuilder.h" 
   45     std::string arraydecl = 
fmt::format(
"array<{}>", decl);
 
   47     AngelScript::CScriptArray* arr = AngelScript::CScriptArray::Create(typeinfo, vec.size());
 
   49     for (AngelScript::asUINT i = 0; i < arr->GetSize(); i++)
 
   53         arr->SetValue(i, &tempval);
 
   59 template <
typename T, 
typename U>
 
   60 AngelScript::CScriptArray* 
MapToScriptArray(std::map<T, U>& map, 
const std::string& decl)
 
   62     std::string arraydecl = 
fmt::format(
"array<{}>", decl);
 
   64     AngelScript::CScriptArray* arr = AngelScript::CScriptArray::Create(typeinfo, map.size());
 
   66     for (
auto itor = map.begin(); itor != map.end(); itor++)
 
   69         AngelScript::asUINT pos = 
static_cast<AngelScript::asUINT
>(std::distance(map.begin(), itor));
 
   70         arr->SetValue(pos, &itor->second);
 
   78 template <
typename ItorT>
 
   81     std::string arraydecl = 
fmt::format(
"array<{}>", decl);
 
   83     AngelScript::CScriptArray* arr = AngelScript::CScriptArray::Create(typeinfo);
 
   85     for (
auto itor = begin; itor != end; itor++)
 
   87         arr->InsertLast(&itor->second);
 
   93 template <
typename ItorT>
 
   96     std::string arraydecl = 
fmt::format(
"array<{}>", decl);
 
   98     AngelScript::CScriptArray* arr = AngelScript::CScriptArray::Create(typeinfo);
 
  100     for (
auto itor = begin; itor != end; itor++)
 
  102         arr->InsertLast(&itor);
 
  109 bool GetValueFromScriptDict(
const std::string& log_msg, AngelScript::CScriptDictionary* dict, 
bool required, std::string 
const& key, 
const char* decl, T & out_value)
 
  120     auto itor = dict->find(key);
 
  121     if (itor == dict->end())
 
  132     const int actual_typeid = itor.GetTypeId();
 
  133     if (actual_typeid != expected_typeid)
 
  144     return itor.GetValue(&out_value, actual_typeid); 
 
  158     bool Exists(
const std::string& key)
 const 
  165         if (
m_map.size() == 0)
 
  173         return AngelScript::asUINT(
m_map.size());
 
  178         auto it = 
m_map.find(key);
 
  179         if (it != 
m_map.end())
 
  188         AngelScript::CScriptArray* array = AngelScript::CScriptArray::Create(AngelScript::asGetActiveContext()->GetEngine()->GetTypeInfoByDecl(
"array<string>"), AngelScript::asUINT(
m_map.size()));
 
  190         for (
auto it = 
m_map.begin(); it != 
m_map.end(); it++)
 
  193             *(std::string*)array->At(current) = it->first;
 
  201         using namespace AngelScript;
 
  214         std::string opIndexDecl = 
fmt::format(
"{}@ opIndex(const string &in)", value_decl);
 
  216         std::string opIndexConstDecl = 
fmt::format(
"const {}@ opIndex(const string &in) const", value_decl);
 
  225     const std::map<std::string, T>& 
m_map;
 
  229 template <
typename T>
 
  236     bool IsEmpty()
 const { 
return m_vec.empty(); }
 
  237     unsigned GetSize()
 const { 
return m_vec.size(); }
 
  238     T 
OpIndex(
unsigned pos) { 
return m_vec.at(pos); }
 
  242         using namespace AngelScript;
 
  253         std::string opIndexDecl = 
fmt::format(
"{}@ opIndex(uint pos)", value_decl);
 
  255         std::string opIndexConstDecl = 
fmt::format(
"const {}@ opIndex(uint pos) const", value_decl);
 
  269 template<
class A, 
class B>
 
  276     B* b = 
dynamic_cast<B*
>(a);
 
  286 template<
class A, 
class B>
 
  293     return dynamic_cast<B*
>(a);
 
  300 #endif // USE_ANGELSCRIPT