mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0027258: Configuration - generate built-in replacement for mandatory resource files
Generation of header files from resource files was added to CMake and genproj procedures. Message_MsgFile has been extended with new method ::LoadFromString() for loading messages from embedded resources. Message_MsgFile::LoadFromString() is now a preferred way for loading message resources by application as alternative to environment variables. TObje/TObj.msg is now embedded into TObj_Application.cxx. TObj_Application now loads its global messages on instantiation of the first class instance. UnitsAPI/Lexi_Expr.dat now completely embedded into Units_Lexicon.cxx. UnitsAPI/Units.dat now embedded into Units_UnitsDictionary.cxx but can be regenerated from resource file. The definition of the following units have been removed: benne à charbon, calorie (diététique). Unused message files XSMessage/IGES.us and IGES.fr have been removed. Related code IGESData.cxx has been removed as well. XSMessage/XSTEP.us is now embedded into Interface_StaticStandards.cxx and used for fallback initialization in case when file resources defined by CSF_XSMessage environment variable are missing. SHMessage/SHAPE.us is now embedded into ShapeExtend.cxx and used for fallback initialization in case when file resources defined by CSF_XHMessage environment variable are missing. Duplicating code has been removed from ShapeProcess_OperLibrary.cxx. Shaders/Declarations.glsl and Shaders/DeclarationsImpl.glsl are now embedded into OpenGl_ShaderProgram.cxx. CSF_ShadersDirectory is no more required for using OCCT 3D Viewer. Ray-Tracing GLSL programs from Shaders are now embedded into OpenGl_View_Raytrace.cxx. File resources are still used instead of embedded programs when CSF_ShadersDirectory is defined, but this functionality is intended for OCCT development. Enumeration Graphic3d_ShaderProgram::ShaderName_Phong demonstrating custom GLSL program usage has been removed.
This commit is contained in:
@@ -271,35 +271,67 @@ Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName)
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadFromEnv
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Message_MsgFile::LoadFromEnv
|
||||
(const Standard_CString envname,
|
||||
const Standard_CString filename,
|
||||
const Standard_CString ext)
|
||||
Standard_Boolean Message_MsgFile::LoadFromEnv (const Standard_CString theEnvName,
|
||||
const Standard_CString theFileName,
|
||||
const Standard_CString theLangExt)
|
||||
{
|
||||
Standard_CString extname = ext;
|
||||
TCollection_AsciiString extstr;
|
||||
if (!extname || extname[0] == '\0') {
|
||||
OSD_Environment extenv("CSF_LANGUAGE");
|
||||
extstr = extenv.Value();
|
||||
extname = extstr.ToCString();
|
||||
}
|
||||
if (!extname || extname[0] == '\0') extname = "us";
|
||||
|
||||
TCollection_AsciiString filestr(filename);
|
||||
if (envname && envname[0] != '\0') {
|
||||
OSD_Environment envenv(envname);
|
||||
TCollection_AsciiString envstr = envenv.Value();
|
||||
if (envstr.Length() > 0) {
|
||||
if (envstr.Value(envstr.Length()) != '/') filestr.Insert (1,'/');
|
||||
filestr.Insert (1,envstr.ToCString());
|
||||
TCollection_AsciiString aLangExt (theLangExt != NULL ? theLangExt : "");
|
||||
if (aLangExt.IsEmpty())
|
||||
{
|
||||
OSD_Environment aLangEnv ("CSF_LANGUAGE");
|
||||
aLangExt = aLangEnv.Value();
|
||||
if (aLangExt.IsEmpty())
|
||||
{
|
||||
aLangExt = "us";
|
||||
}
|
||||
}
|
||||
if (extname[0] != '.') filestr.AssignCat ('.');
|
||||
filestr.AssignCat (extname);
|
||||
|
||||
Message_MsgFile::LoadFile (filestr.ToCString());
|
||||
TCollection_AsciiString aFilePath (theFileName);
|
||||
if (theEnvName != NULL
|
||||
&& theEnvName[0] != '\0')
|
||||
{
|
||||
OSD_Environment aNameEnv (theEnvName);
|
||||
TCollection_AsciiString aNameEnvStr = aNameEnv.Value();
|
||||
if (!aNameEnvStr.IsEmpty())
|
||||
{
|
||||
if (aNameEnvStr.Value (aNameEnvStr.Length()) != '/')
|
||||
{
|
||||
aFilePath.Insert (1, '/');
|
||||
}
|
||||
aFilePath.Insert (1, aNameEnvStr);
|
||||
}
|
||||
}
|
||||
|
||||
if (aLangExt.Value (1) != '.')
|
||||
{
|
||||
aFilePath.AssignCat ('.');
|
||||
}
|
||||
aFilePath.AssignCat (aLangExt);
|
||||
|
||||
return Message_MsgFile::LoadFile (aFilePath.ToCString());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Message_MsgFile::LoadFromString (const Standard_CString theContent,
|
||||
const Standard_Integer theLength)
|
||||
{
|
||||
Standard_Integer aStringSize = theLength >= 0 ? theLength : (Standard_Integer )strlen (theContent);
|
||||
NCollection_Buffer aBuffer (NCollection_BaseAllocator::CommonBaseAllocator());
|
||||
if (aStringSize <= 0 || !aBuffer.Allocate (aStringSize + 2))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
memcpy (aBuffer.ChangeData(), theContent, aStringSize);
|
||||
aBuffer.ChangeData()[aStringSize + 0] = '\0';
|
||||
aBuffer.ChangeData()[aStringSize + 1] = '\0';
|
||||
char* anMsgBuffer = reinterpret_cast<char*>(aBuffer.ChangeData());
|
||||
return ::loadFile (anMsgBuffer);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -25,7 +25,6 @@
|
||||
class TCollection_AsciiString;
|
||||
class TCollection_ExtendedString;
|
||||
|
||||
|
||||
//! A tool providing facility to load definitions of message strings from
|
||||
//! resource file(s).
|
||||
//!
|
||||
@@ -67,14 +66,25 @@ public:
|
||||
//! are replaced with the new ones.
|
||||
Standard_EXPORT static Standard_Boolean LoadFile (const Standard_CString theFName);
|
||||
|
||||
//! Loads the messages from the file with name (without extension)
|
||||
//! given by environment variable.
|
||||
//! Extension of the file name is given separately. If its not
|
||||
//! defined, it is taken:
|
||||
//! Loads the messages from the file with name (without extension) given by environment variable.
|
||||
//! Extension of the file name is given separately. If its not defined, it is taken:
|
||||
//! - by default from environment CSF_LANGUAGE,
|
||||
//! - if not defined either, as "us".
|
||||
Standard_EXPORT static void LoadFromEnv (const Standard_CString envname, const Standard_CString filename, const Standard_CString ext = "");
|
||||
|
||||
//! @name theEnvName environment variable name
|
||||
//! @name theFileName file name without language suffix
|
||||
//! @name theLangExt language file name extension
|
||||
//! @return TRUE on success
|
||||
Standard_EXPORT static Standard_Boolean LoadFromEnv (const Standard_CString theEnvName,
|
||||
const Standard_CString theFileName,
|
||||
const Standard_CString theLangExt = "");
|
||||
|
||||
//! Loads the messages from the given text buffer.
|
||||
//! @param theContent string containing the messages
|
||||
//! @param theLength length of the buffer;
|
||||
//! when -1 specified - theContent will be considered as NULL-terminated string
|
||||
Standard_EXPORT static Standard_Boolean LoadFromString (const Standard_CString theContent,
|
||||
const Standard_Integer theLength = -1);
|
||||
|
||||
//! Adds new message to the map. Parameter <key> gives
|
||||
//! the key of the message, <text> defines the message itself.
|
||||
//! If there already was defined the message identified by the
|
||||
|
Reference in New Issue
Block a user