Esempio n. 1
0
std::string FileHandler::getOutputFilename(const std::string& inputFilename)
{
	std::string outputFilename(inputFilename);
	replaceSubstring(outputFilename, m_inputPrefix, m_outputPrefix);
	replaceSubstring(outputFilename, m_inputSuffix, m_outputSuffix);
	return outputFilename;
}
Esempio n. 2
0
void FileHandler::setOutputFolders()
{
	for (int i = 0; i < m_inputFolders.size(); ++i)
	{
		replaceSubstring(m_outputFolders[i], m_input_root, m_output_root);
		replaceSubstring(m_outputFolders[i], "\\input", "");
	}

}
Esempio n. 3
0
        RAYTRACER_EXPORTS static std::string getParentDirectoryFromFilePath(std::string filePath) {
            replaceSubstring(filePath, "\\", "/");
            std::string::reverse_iterator sit = filePath.rbegin();
            int stopAt(0);
            while (stopAt != 2 && sit != filePath.rend()) {
                if ((*sit) == '/')
                    ++stopAt;
                ++sit;
            }

            std::string directory(sit, filePath.rend());
            std::reverse(directory.begin(), directory.end());
            directory += "/";
            return directory;
        }
Esempio n. 4
0
// Remove a substring ......................................................
FileName FileName::removeSubstring(const String &sub) const
{
    return replaceSubstring(sub, "");
}
Esempio n. 5
0
void HK_CALL DumpHavokClassHeader(hkClass* hclass)
{
   char fbuffer[260], buffer[1024];
   const char *ptr = hclass->getName();
   int ver = hclass->getDescribedVersion();
   sprintf_s(fbuffer, 256, "%s\\%s_%d.h", s_rootPath, ptr, ver);

   char outdir[MAX_PATH];
   strcpy(outdir, fbuffer);
   PathRemoveFileSpec(outdir);
   CreateDirectories(outdir);

   hkClass* pParent = hclass->getParent();
   FILE *hFile = NULL; fopen_s(&hFile, fbuffer, "wt" );
   if ( hFile != NULL )
   {
      PrintLine(hFile, "#pragma once");
      PrintLine(hFile, "");
      PrintLine(hFile, "#include <Common/Base/hkBase.h>");
      std::set<string> nameMap;
      if (pParent != NULL) 
      {
         LPCSTR hdrName = LookupClassHeader(pParent->getName());
         if (hdrName != NULL) PrintLine(hFile, "#include <%s>", hdrName);
         else PrintLine(hFile, "#include \"%s_%d.h\"", pParent->getName(), pParent->getDescribedVersion());
         nameMap.insert(string(pParent->getName()));
      }
      for (int i=0,n=hclass->getNumDeclaredMembers();i<n;++i)
      {
         const hkClassMember &mem = hclass->getDeclaredMember(i);         
         if ( mem.hasClass() )
         {
            if ( const hkClass* mClass = mem.getClass() )
            {
               string name = mClass->getName();
               if (nameMap.find(name) == nameMap.end())
               {
                  nameMap.insert(name);
                  LPCSTR hdrName = LookupClassHeader(mClass->getName());
                  if (hdrName != NULL) PrintLine(hFile, "#include <%s>", hdrName);
                  else PrintLine(hFile, "#include \"%s_%d.h\"", name.c_str(), mClass->getDescribedVersion());
               }
            }            
         }
      }

      PrintLine(hFile, "");
      if (!hclass->hasVtable())
      {
         if (pParent != NULL) PrintLine(hFile, "struct %s : public %s", ptr, pParent->getName());
         else PrintLine(hFile, "struct %s", ptr);
      }
      else
      {
         if (pParent != NULL) PrintLine(hFile, "class %s : public %s", ptr, pParent->getName());
         else PrintLine(hFile, "class %s", ptr);
      }
      PrintLine(hFile, "{");
      if (hclass->hasVtable())
      {
         PrintLine(hFile, "public:");
         PrintLine(hFile, "   HK_DECLARE_CLASS_ALLOCATOR( HK_MEMORY_CLASS_BEHAVIOR_RUNTIME );");
      }
      else
      {
         PrintLine(hFile, "   HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_BEHAVIOR_RUNTIME, %s );", ptr);
      }
      PrintLine(hFile, "   HK_DECLARE_REFLECTION();");
      PrintLine(hFile, "");
      if (hclass->hasVtable())
         PrintLine(hFile, "public:");

      PrintLine(hFile, "   HK_FORCE_INLINE %s(void) {}", ptr);
      if (hclass->hasVtable())
      {
         bool first = pParent == NULL;
         if (pParent == NULL)
            PrintLine(hFile, "   HK_FORCE_INLINE %s( hkFinishLoadedObjectFlag flag ) ", ptr);
         else 
            PrintLine(hFile, "   HK_FORCE_INLINE %s( hkFinishLoadedObjectFlag flag ) : %s(flag) ", ptr, pParent->getName());
         for (int i=0,n=hclass->getNumDeclaredMembers();i<n;++i)
         {
            const hkClassMember &mem = hclass->getDeclaredMember(i);
            switch (mem.getType())
            {
            case hkClassMember::TYPE_POINTER:
            case hkClassMember::TYPE_ARRAY:
            case hkClassMember::TYPE_STRINGPTR:
            case hkClassMember::TYPE_VARIANT:
               if (first) PrintLine(hFile, "     m_%s(flag)", mem.getName());
               else PrintLine(hFile, "   , m_%s(flag)", mem.getName());
               first = false;
               break;
            }
         }
         PrintLine(hFile, "      {}");
      }

      for (int i=0,n=hclass->getNumDeclaredEnums();i<n;++i)
      {
         const hkClassEnum &hEnum = hclass->getDeclaredEnum(i);
         PrintLine(hFile, "   enum %s", hEnum.getName());
         PrintLine(hFile, "   {");
         for (int j=0,m=hEnum.getNumItems();j<m;++j)
         {
            const hkClassEnum::Item& item = hEnum.getItem(j);
            PrintLine(hFile, "      %s = %d,", item.getName(),item.getValue());
         }
         PrintLine(hFile, "   };");
         PrintLine(hFile, "");
      }         

      PrintLine(hFile, "   // Properties");

      for (int i=0,n=hclass->getNumDeclaredMembers();i<n;++i)
      {
         const hkClassMember &mem = hclass->getDeclaredMember(i);         

         bool print=true;
         string typeName;

         switch (mem.getType())
         {
         case hkClassMember::TYPE_ENUM:
            typeName = EnumToString(mem.getSubType(), CTypeEnums);
            if (mem.hasEnumClass())
            {
               PrintLine(hFile, "   hkEnum<%s,%s> m_%s;", mem.getEnumClass().getName(), typeName.c_str(), mem.getName());
               print=false;
            }
            else if (typeName.substr(0,2).compare("0x") != 0)
            {
               PrintLine(hFile, "   /*enum*/ %s m_%s;", typeName.c_str(), mem.getName());
               print=false;
            }            
            break;

         case hkClassMember::TYPE_FLAGS:
            typeName = EnumToString(mem.getSubType(), CTypeEnums);
            if (mem.hasEnumClass())
            {
               PrintLine(hFile, "   hkFlags<%s,%s> m_%s;", mem.getEnumClass().getName(), typeName.c_str(), mem.getName());
               print=false;
            }
            else if (typeName.substr(0,2).compare("0x") != 0)
            {
               PrintLine(hFile, "   /*flags*/ %s m_%s;", typeName.c_str(), mem.getName());
               print=false;
            }
            else 
               break;
         }
         if (print)
         {
            mem.getTypeName(buffer, 1024);
            typeName = buffer;
            typeName = replaceSubstring(typeName, "&lt;", "<");
            typeName = replaceSubstring(typeName, "&gt;", ">");
            typeName = replaceSubstring(typeName, "void*", "hkRefVariant");
            typeName = replaceSubstring(typeName, "<void>", "<hkRefVariant>");
            if ( hkClassMember::TYPE_POINTER == mem.getType() )
            {
               if ( typeName.substr(typeName.length()-1,1).compare("*") == 0 )
               {
                  typeName.replace(typeName.length()-1,1,1,'>');
                  typeName.insert(0, "hkRefPtr<");
               }
            }
            typeName = replaceSubstring(typeName, "struct ", "");

            if (mem.getCstyleArraySize() > 0)
            {
               string arString = FormatString("[%d]",mem.getCstyleArraySize());
               typeName = replaceSubstring(typeName, arString, "");
               PrintLine(hFile, "   %s m_%s%s;", typeName.c_str(), mem.getName(), arString.c_str());               
            }
            else
            {
               PrintLine(hFile, "   %s m_%s;", typeName.c_str(), mem.getName());
            }
         }
      }
      PrintLine(hFile, "};");
      PrintLine(hFile, "extern const hkClass %sClass;", ptr);
      PrintLine(hFile, "");
      fflush(hFile);
      fclose(hFile);
   }
}