mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
5
src/Resource/FILES
Executable file
5
src/Resource/FILES
Executable file
@@ -0,0 +1,5 @@
|
||||
Resource_CMPLRS.edl
|
||||
Resource_ConvertUnicode.c
|
||||
Resource_ConvertUnicode.hxx
|
||||
Resource_Shiftjis.h
|
||||
Resource_gb2312.h
|
56
src/Resource/Resource.cdl
Executable file
56
src/Resource/Resource.cdl
Executable file
@@ -0,0 +1,56 @@
|
||||
-- File: PrefKernel.cdl
|
||||
-- Created: Thu Apr 20 17:23:58 1995
|
||||
-- Author: Tony GEORGIADES
|
||||
-- <tge@kikox>
|
||||
-- Modified Tue Sep 19 1995 by Jean-Louis Frenkel
|
||||
-- Modified Tue Jan 19 1999 by Louis Dusuzeau
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
package Resource
|
||||
---Purpose: Resources management.
|
||||
-- A RESOURCE is a parameter saved on a file and used to
|
||||
-- initialize a variable.
|
||||
|
||||
uses
|
||||
TCollection,MMgt,SortTools,TColStd
|
||||
is
|
||||
|
||||
enumeration FormatType is
|
||||
SJIS,
|
||||
EUC,
|
||||
ANSI,
|
||||
GB
|
||||
end FormatType ;
|
||||
---Purpose:
|
||||
-- List of non ASCII format types which may be
|
||||
-- converted into the Unicode 16 bits format type.
|
||||
-- Use the functions provided by the
|
||||
-- Resource_Unicode class to convert a string
|
||||
-- from one of these non ASCII format to Unicode, and vice versa.
|
||||
|
||||
class DataMapOfAsciiStringAsciiString instantiates
|
||||
DataMap from TCollection(AsciiString from TCollection,
|
||||
AsciiString from TCollection,
|
||||
AsciiString from TCollection) ;
|
||||
|
||||
class DataMapOfAsciiStringExtendedString instantiates
|
||||
DataMap from TCollection(AsciiString from TCollection,
|
||||
ExtendedString from TCollection,
|
||||
AsciiString from TCollection) ;
|
||||
|
||||
class QuickSortOfArray1 instantiates
|
||||
QuickSort from SortTools(AsciiString from TCollection,
|
||||
Array1OfAsciiString from TColStd,
|
||||
LexicalCompare from Resource) ;
|
||||
|
||||
---Class:
|
||||
class LexicalCompare ;
|
||||
|
||||
class Manager;
|
||||
---Purpose: Defines a resource structure and its management methods.
|
||||
|
||||
class Unicode;
|
||||
|
||||
exception NoSuchResource inherits NoSuchObject from Standard;
|
||||
|
||||
end Resource;
|
22
src/Resource/Resource_CMPLRS.edl
Executable file
22
src/Resource/Resource_CMPLRS.edl
Executable file
@@ -0,0 +1,22 @@
|
||||
-- File: _CMPLRS.edl
|
||||
-- Author: Jean GAUTIER
|
||||
-- History: Mon Feb 19 12:04:00 1996 Jean GAUTIER Creation
|
||||
-- Copyright: Matra Datavision 1996
|
||||
|
||||
@ifnotdefined ( %Resource_CMPLRS_EDL ) then
|
||||
@set %Resource_CMPLRS_EDL = "";
|
||||
|
||||
-- Templates HP-UX
|
||||
|
||||
@if ( %Station == "hp" ) then
|
||||
@string %CMPLRS_C_Command = %CMPLRS_C_Command " -Aa";
|
||||
|
||||
@endif;
|
||||
|
||||
@endif;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
224
src/Resource/Resource_ConvertUnicode.c
Executable file
224
src/Resource/Resource_ConvertUnicode.c
Executable file
@@ -0,0 +1,224 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef unsigned short char16 ;
|
||||
|
||||
#include <Resource_Shiftjis.h>
|
||||
#include <Resource_gb2312.h>
|
||||
|
||||
#define isjis(c) (((c)>=0x21 && (c)<=0x7e))
|
||||
#define iseuc(c) (((c)>=0xa1 && (c)<=0xfe))
|
||||
#define issjis1(c) (((c)>=0x81 && (c)<=0x9f) || ((c)>=0xe0 && (c)<=0xef))
|
||||
#define issjis2(c) ((c)>=0x40 && (c)<=0xfc && (c)!=0x7f)
|
||||
#define ishankana(c) ((c)>=0xa0 && (c)<=0xdf)
|
||||
#define isshift(c) (((c)>=0x80 && (c)<=0xff))
|
||||
|
||||
|
||||
static void sjis_to_jis (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
|
||||
if ( ! issjis1 ( *ph ) || ! issjis2 ( *pl ) ) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (*ph <= 0x9f)
|
||||
{
|
||||
if (*pl < 0x9f)
|
||||
*ph = (*ph << 1) - 0xe1;
|
||||
else
|
||||
*ph = (*ph << 1) - 0xe0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*pl < 0x9f)
|
||||
*ph = (*ph << 1) - 0x161;
|
||||
else
|
||||
*ph = (*ph << 1) - 0x160;
|
||||
}
|
||||
if (*pl < 0x7f)
|
||||
*pl -= 0x1f;
|
||||
else if (*pl < 0x9f)
|
||||
*pl -= 0x20;
|
||||
else
|
||||
*pl -= 0x7e;
|
||||
}
|
||||
|
||||
static void jis_to_sjis (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
if (*ph & 1)
|
||||
{
|
||||
if (*pl < 0x60)
|
||||
*pl += 0x1f;
|
||||
else
|
||||
*pl += 0x20;
|
||||
}
|
||||
else
|
||||
*pl += 0x7e;
|
||||
if (*ph < 0x5f)
|
||||
*ph = (*ph + 0xe1) >> 1;
|
||||
else
|
||||
*ph = (*ph + 0x161) >> 1;
|
||||
}
|
||||
|
||||
static void euc_to_sjis (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
if ( (*ph & 0xFFFFFF00) || (*pl & 0xFFFFFF00) ) {
|
||||
*ph = 0 ;
|
||||
*pl = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( ! iseuc ( *ph ) || ! iseuc ( *pl ) ) {
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
*ph &= 0x7F ;
|
||||
*pl &= 0x7F ;
|
||||
|
||||
jis_to_sjis ( ph , pl ) ;
|
||||
|
||||
}
|
||||
|
||||
static void sjis_to_euc (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
if ( (*ph & 0xFFFFFF00) || (*pl & 0xFFFFFF00) ) {
|
||||
*ph = 0 ;
|
||||
*pl = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( ! issjis1 ( *ph ) || ! issjis2 ( *pl ) ) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( *ph == 0 && *pl == 0 )
|
||||
return ;
|
||||
|
||||
sjis_to_jis ( ph , pl ) ;
|
||||
|
||||
*ph |= 0x80 ;
|
||||
*pl |= 0x80 ;
|
||||
|
||||
}
|
||||
|
||||
void Resource_sjis_to_unicode (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
char16 sjis ;
|
||||
char16 uni ;
|
||||
|
||||
if ( (*ph & 0xFFFFFF00) || (*pl & 0xFFFFFF00) ) {
|
||||
*ph = 0 ;
|
||||
*pl = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( ! issjis1 ( *ph ) || ! issjis2 ( *pl ) ) {
|
||||
return ;
|
||||
}
|
||||
|
||||
sjis = ((*ph) << 8) | (*pl) ;
|
||||
uni = sjisuni [sjis] ;
|
||||
*ph = uni >> 8 ;
|
||||
*pl = uni & 0xFF ;
|
||||
}
|
||||
|
||||
void Resource_unicode_to_sjis (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
char16 sjis ;
|
||||
char16 uni ;
|
||||
|
||||
if ( (*ph & 0xFFFFFF00) || (*pl & 0xFFFFFF00) ) {
|
||||
*ph = 0 ;
|
||||
*pl = 0 ;
|
||||
return ;
|
||||
}
|
||||
if ( *ph == 0 && *pl == 0 )
|
||||
return ;
|
||||
|
||||
uni = ((*ph) << 8) | (*pl) ;
|
||||
sjis = unisjis [uni] ;
|
||||
*ph = sjis >> 8 ;
|
||||
*pl = sjis & 0xFF ;
|
||||
}
|
||||
|
||||
void Resource_unicode_to_euc (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
|
||||
if ( *ph == 0 && *pl == 0 )
|
||||
return ;
|
||||
|
||||
Resource_unicode_to_sjis ( ph , pl ) ;
|
||||
if (issjis1(*ph)) { /* let's believe it is ANSI code if it is not sjis*/
|
||||
sjis_to_euc ( ph , pl ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Resource_euc_to_unicode (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
|
||||
if ( ! iseuc ( *ph ) || ! iseuc ( *pl ) ) {
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
if ( *ph == 0 && *pl == 0 )
|
||||
return ;
|
||||
|
||||
euc_to_sjis ( ph , pl ) ;
|
||||
Resource_sjis_to_unicode ( ph , pl ) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Resource_gb_to_unicode (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
char16 gb ;
|
||||
char16 uni ;
|
||||
|
||||
|
||||
if ( (*ph & 0xFFFFFF00) || (*pl & 0xFFFFFF00) ) {
|
||||
*ph = 0 ;
|
||||
*pl = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( ! isshift ( *ph ) || ! isshift ( *pl ) ) {
|
||||
return ;
|
||||
}
|
||||
|
||||
*ph = (*ph) & 0x7f ;
|
||||
*pl = (*pl) & 0x7f ;
|
||||
|
||||
gb = ((*ph) << 8) | (*pl) ;
|
||||
uni = gbuni [gb] ;
|
||||
*ph = uni >> 8 ;
|
||||
*pl = uni & 0xFF ;
|
||||
}
|
||||
|
||||
void Resource_unicode_to_gb (unsigned int *ph, unsigned int *pl)
|
||||
{
|
||||
char16 gb ;
|
||||
char16 uni ;
|
||||
|
||||
if ( (*ph & 0xFFFFFF00) || (*pl & 0xFFFFFF00) ) {
|
||||
*ph = 0 ;
|
||||
*pl = 0 ;
|
||||
return ;
|
||||
}
|
||||
if ( *ph == 0 && *pl == 0 )
|
||||
return ;
|
||||
|
||||
uni = ((*ph) << 8) | (*pl) ;
|
||||
gb = unigb [uni] ;
|
||||
if (gb != 0) {
|
||||
*ph = ( gb >> 8 ) | 0x80 ;
|
||||
*pl = ( gb & 0xFF ) | 0x80 ;
|
||||
}
|
||||
else {
|
||||
*ph = 0;
|
||||
*pl = 0 ;
|
||||
}
|
||||
}
|
22
src/Resource/Resource_ConvertUnicode.hxx
Executable file
22
src/Resource/Resource_ConvertUnicode.hxx
Executable file
@@ -0,0 +1,22 @@
|
||||
// Copyright: Matra-Datavision 1996
|
||||
// File: Resource_ConvertUnicode.hxx
|
||||
// Created: Mon Sep 30 10:03:04 1996
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
|
||||
#ifndef Resource_ConvertUnicode_HeaderFile
|
||||
#define Resource_ConvertUnicode_HeaderFile
|
||||
|
||||
extern "C" {
|
||||
|
||||
void Resource_sjis_to_unicode (unsigned int *ph, unsigned int *pl);
|
||||
void Resource_unicode_to_sjis (unsigned int *ph, unsigned int *pl);
|
||||
void Resource_unicode_to_euc (unsigned int *ph, unsigned int *pl);
|
||||
void Resource_euc_to_unicode (unsigned int *ph, unsigned int *pl);
|
||||
void Resource_gb_to_unicode(unsigned int *ph, unsigned int *pl);
|
||||
void Resource_unicode_to_gb(unsigned int *ph, unsigned int *pl);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
19
src/Resource/Resource_LexicalCompare.cdl
Executable file
19
src/Resource/Resource_LexicalCompare.cdl
Executable file
@@ -0,0 +1,19 @@
|
||||
-- File: Resource_KeyComparator.cdl
|
||||
-- Created: Fri Dec 4 15:14:36 1998
|
||||
-- Author: DUSUZEAU Louis
|
||||
-- <ld@dekpon.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
class LexicalCompare from Resource
|
||||
|
||||
uses
|
||||
AsciiString from TCollection
|
||||
is
|
||||
|
||||
Create ;
|
||||
|
||||
IsLower (me; Left, Right: AsciiString)
|
||||
---Purpose: Returns True if <Left> is lower than <Right>.
|
||||
returns Boolean ;
|
||||
|
||||
end;
|
23
src/Resource/Resource_LexicalCompare.cxx
Executable file
23
src/Resource/Resource_LexicalCompare.cxx
Executable file
@@ -0,0 +1,23 @@
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Resource_LexicalCompare.hxx>
|
||||
|
||||
|
||||
// -----------
|
||||
// Create :
|
||||
// -----------
|
||||
|
||||
Resource_LexicalCompare::Resource_LexicalCompare()
|
||||
{
|
||||
}
|
||||
|
||||
// -----------
|
||||
// IsLower :
|
||||
// -----------
|
||||
|
||||
Standard_Boolean Resource_LexicalCompare::IsLower (
|
||||
const TCollection_AsciiString& Left,
|
||||
const TCollection_AsciiString& Right) const
|
||||
{
|
||||
return Left.IsLess(Right) ;
|
||||
}
|
||||
|
247
src/Resource/Resource_Manager.cdl
Executable file
247
src/Resource/Resource_Manager.cdl
Executable file
@@ -0,0 +1,247 @@
|
||||
-- File: Resources_Manager.cdl
|
||||
-- Created: Thu Apr 20 17:34:44 1995
|
||||
-- Author: Tony GEORGIADES
|
||||
-- <tge@kikox>
|
||||
-- Modified Tue Sep 19 1995 by Jean-Louis Frenkel
|
||||
-- Modified Tue Jan 19 1999 by Louis Dusuzeau
|
||||
-- Modified Fri Feb 15 2002 by Sergey Telkov
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class Manager from Resource inherits TShared from MMgt
|
||||
---Purpose: Defines a resource structure and its management methods.
|
||||
|
||||
uses
|
||||
|
||||
AsciiString from TCollection,
|
||||
ExtendedString from TCollection,
|
||||
DataMapOfAsciiStringAsciiString from Resource,
|
||||
DataMapOfAsciiStringExtendedString from Resource
|
||||
|
||||
raises TypeMismatch from Standard, NoSuchResource from Resource,
|
||||
OutOfRange from Standard
|
||||
is
|
||||
|
||||
---Category: class constructor
|
||||
|
||||
Create(aName: CString from Standard;Verbose: Boolean from Standard = Standard_False)
|
||||
returns mutable Manager from Resource;
|
||||
---Purpose: Create a Resource manager.
|
||||
-- Attempts to find the two following files:
|
||||
-- $CSF_`aName`Defaults/aName
|
||||
-- $CSF_`aName`UserDefaults/aName
|
||||
-- and load them respectively into a reference and a user resource structure.
|
||||
--
|
||||
-- If CSF_ResourceVerbose defined, seeked files will be printed.
|
||||
--
|
||||
-- FILE SYNTAX
|
||||
-- The syntax of a resource file is a sequence of resource
|
||||
-- lines terminated by newline characters or end of file. The
|
||||
-- syntax of an individual resource line is:
|
||||
|
||||
-- ResourceLine = Comment | IncludeFile | ResourceSpec | <empty line>
|
||||
-- Comment = "!" {<any character except null or newline>}
|
||||
-- IncludeFile = "#" WhiteSpace "include" WhiteSpace FileName WhiteSpace
|
||||
-- FileName = <valid filename for operating system>
|
||||
-- ResourceSpec = WhiteSpace ResourceName WhiteSpace ":" WhiteSpace Value
|
||||
-- ResourceName = NameChar {NameChar}
|
||||
-- WhiteSpace = {<space> | <horizontal tab>}
|
||||
-- NameChar = "a"-"z" | "A"-"Z" | "0"-"9" | "_" | "-"
|
||||
-- Value = {<any character except null or unescaped newline>}
|
||||
|
||||
-- Elements separated by vertical bar (|) are alternatives.
|
||||
-- Curly braces ({...}) indicate zero or more repetitions of
|
||||
-- the enclosed elements. Quotes ("...") are used around literal
|
||||
-- characters.
|
||||
|
||||
-- IncludeFile lines are interpreted by replacing the line with
|
||||
-- the contents of the specified file. The word "include" must
|
||||
-- be in lowercase. The filename is interpreted relative to
|
||||
-- the directory of the file in which the line occurs (for
|
||||
-- example, if the filename contains no directory or contains a
|
||||
-- relative directory specification).
|
||||
|
||||
-- A resource database never contains more than one entry for a
|
||||
-- given ResourceName. If a resource file contains multiple
|
||||
-- lines with the same ResourceName, the last line in the file
|
||||
-- is used.
|
||||
|
||||
-- Any whitespace character before or after the name or colon
|
||||
-- in a ResourceSpec are ignored. To allow a Value to begin
|
||||
-- with whitespace, the two-character sequence ``\space''
|
||||
-- (backslash followed by space) is recognized and replaced by
|
||||
-- a space character, and the two-character sequence ``\tab''
|
||||
-- (backslash followed by horizontal tab) is recognized and
|
||||
-- replaced by a horizontal tab character.
|
||||
-- Finally, the two-character sequence ``\\'' is recognized and
|
||||
-- replaced with a single backslash.
|
||||
-- These substitutions are done at the beginning of the value
|
||||
-- and never inside.
|
||||
|
||||
Create(aName: CString from Standard;
|
||||
aDefaultsDirectory: in out AsciiString from TCollection;
|
||||
anUserDefaultsDirectory: in out AsciiString from TCollection;
|
||||
Verbose: Boolean from Standard = Standard_False)
|
||||
returns mutable Manager from Resource;
|
||||
|
||||
Save(me)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Save the user resource structure in the specified file.
|
||||
-- Creates the file if it does not exist.
|
||||
---Level: Public
|
||||
|
||||
---Category: Querying...
|
||||
|
||||
-- A resource is search first in the user structure and then in the reference
|
||||
-- structure. The resource name is case sensitive.
|
||||
|
||||
Find(me; aResource: CString from Standard)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: returns True if the Resource does exist.
|
||||
---Level: Public
|
||||
|
||||
Integer(me; aResourceName: in CString from Standard)
|
||||
returns Integer from Standard
|
||||
raises NoSuchResource from Resource, TypeMismatch from Standard
|
||||
is virtual;
|
||||
|
||||
---Purpose: Gets the value of an integer resource according to its
|
||||
-- instance and its type.
|
||||
---Level: Public
|
||||
|
||||
Real(me; aResourceName: in CString from Standard)
|
||||
returns Real from Standard
|
||||
raises NoSuchResource from Resource, TypeMismatch from Standard
|
||||
is virtual;
|
||||
---Purpose: Gets the value of a real resource according to its instance
|
||||
-- and its type.
|
||||
---Level: Public
|
||||
|
||||
Value(me; aResourceName: in CString from Standard)
|
||||
returns CString from Standard
|
||||
raises NoSuchResource from Resource, TypeMismatch from Standard
|
||||
is virtual;
|
||||
---Purpose: Gets the value of a CString resource according to its instance
|
||||
-- and its type.
|
||||
---Level: Public
|
||||
|
||||
ExtValue(me: mutable; aResourceName: in CString from Standard)
|
||||
returns ExtString from Standard
|
||||
raises NoSuchResource from Resource, TypeMismatch from Standard
|
||||
is virtual;
|
||||
---Purpose: Gets the value of an ExtString resource according to its instance
|
||||
-- and its type.
|
||||
---Level: Public
|
||||
|
||||
---Category: Modifying or creating a resource...
|
||||
|
||||
-- This can be done only in user resource structure, even if the resource
|
||||
-- already exists in the reference structure.
|
||||
|
||||
SetResource(me:mutable;
|
||||
aResourceName: in CString from Standard;
|
||||
aValue: in Integer from Standard)
|
||||
is virtual;
|
||||
---Purpose: Sets the new value of an integer resource.
|
||||
-- If the resource does not exist, it is created.
|
||||
---Level: Public
|
||||
|
||||
SetResource(me: mutable;
|
||||
aResourceName: in CString from Standard;
|
||||
aValue: in Real from Standard)
|
||||
is virtual;
|
||||
---Purpose: Sets the new value of a real resource.
|
||||
-- If the resource does not exist, it is created.
|
||||
---Level: Public
|
||||
|
||||
SetResource(me: mutable;
|
||||
aResourceName: in CString from Standard;
|
||||
aValue: in CString from Standard)
|
||||
is virtual;
|
||||
---Purpose: Sets the new value of an CString resource.
|
||||
-- If the resource does not exist, it is created.
|
||||
---Level: Public
|
||||
|
||||
SetResource(me: mutable;
|
||||
aResourceName: in CString from Standard;
|
||||
aValue: in ExtString from Standard)
|
||||
is virtual;
|
||||
---Purpose: Sets the new value of an ExtString resource.
|
||||
-- If the resource does not exist, it is created.
|
||||
---Level: Public
|
||||
|
||||
---Category: Private methods.
|
||||
|
||||
Load (me: mutable ;
|
||||
aDirectory: in out AsciiString from TCollection;
|
||||
aName: in out AsciiString from TCollection;
|
||||
aMap: in out DataMapOfAsciiStringAsciiString)
|
||||
is static private;
|
||||
---Level: Internal
|
||||
|
||||
fields
|
||||
|
||||
myName : AsciiString from TCollection;
|
||||
myRefMap : DataMapOfAsciiStringAsciiString from Resource ;
|
||||
myUserMap : DataMapOfAsciiStringAsciiString from Resource ;
|
||||
myExtStrMap : DataMapOfAsciiStringExtendedString from Resource ;
|
||||
myVerbose : Boolean from Standard;
|
||||
|
||||
end Manager;
|
||||
|
||||
|
||||
|
||||
-- Examples
|
||||
-- Let's consider the Mesh application.
|
||||
--
|
||||
-- A reference file is furnished:
|
||||
--
|
||||
-- $MESHHOME/inc/Mesh and CSF_MeshDefaults points to $MESHHOME/inc
|
||||
--
|
||||
--
|
||||
--Mesh.Strategy: TransBoundary
|
||||
--Mesh.TransBoundary.DiscontinuityAngle: .8
|
||||
--Mesh.Type.Objective: Surfaces
|
||||
--Mesh.Type.Node.Geometry: Point
|
||||
--Mesh.Type.Line.Geometry: Segment
|
||||
--Mesh.Type.Surface.Geometry: Quadrangle
|
||||
--Mesh.Type.Volume.Geometry: Tetrahedral
|
||||
--Mesh.Type.Point.Element: PointA
|
||||
--Mesh.Type.Segment.Element: SegmentA
|
||||
--Mesh.Type.Triangle.Element: TriangleA
|
||||
--Mesh.Type.Quadrangle.Element: QuadrangleA
|
||||
--Mesh.Type.TriQuad.Element: TriQuadA
|
||||
--Mesh.Type.Tetrahedral.Element: TetrahedralA
|
||||
--Mesh.Type.Point.Method: Mapped
|
||||
--Mesh.Type.Segment.Method: ShellExtrusion
|
||||
--Mesh.Type.Triangle.Method: Frontal
|
||||
--Mesh.Type.Quadrangle.Method: Mapped
|
||||
--Mesh.Type.TriQuad.Method: Mapped
|
||||
--Mesh.Type.Tetrahedral.Method: DelaunayTetra
|
||||
--Mesh.Constraints.DistributionMode.AverageLengthDefinition: MaxLengthRatio
|
||||
--Mesh.Constraints.AverageLength.ByNumberOfNodes: 100
|
||||
--Mesh.Constraints.AverageLength.ByRatio: 10
|
||||
--Mesh.Constraints.DistributionMode.NumberOfDivisions: 4
|
||||
--Mesh.Constraints.DistributionMode.MaximumDeflection: 10
|
||||
--Mesh.Constraints.DistributionMode.Position: Centered
|
||||
--Mesh.Constraints.DistributionMode.ArithmRatio: 10
|
||||
--Mesh.Constraints.DistributionMode.GeomCoeff: 2.0
|
||||
--Mesh.Constraints.DistributionMode.Circles.MiniDivision: 5
|
||||
--Mesh.Constraints.ElementsQuality.Triangle: Hard
|
||||
--Mesh.Constraints.ElementsQuality.Quadrangle: Normal
|
||||
--Mesh.Constraints.ElementsQuality.Tetrahedral: Tolerant
|
||||
--Mesh.Constraints.ElementsQuality.Quadrangle.Criterium: 0.2
|
||||
--Mesh.Constraints.ElementsQuality.Tetrahedral.Criterium: 0.15
|
||||
--Mesh.Constraints.ElementsQuality.Triangle.Criterium: 0.1
|
||||
--Mesh.Edition.SmoothIterationNumber: 10
|
||||
--Mesh.Edition.NodesPastingTolerance: 0.3
|
||||
--Mesh.Control.Length: 10.0
|
||||
--Mesh.Control.Surface: 100.0
|
||||
--Mesh.Control.Volume: 10000.0
|
||||
--Mesh.Control.Warp: 0.6
|
||||
--Mesh.Control.AspectRatio: 2.0
|
||||
--
|
||||
-- A user file is (or is not) furnished:
|
||||
--
|
||||
--
|
||||
-- $HOME/Mesh and CSF_MeshUserDefaults points to $HOME
|
||||
-- which can override some or all the previous values.
|
452
src/Resource/Resource_Manager.cxx
Executable file
452
src/Resource/Resource_Manager.cxx
Executable file
@@ -0,0 +1,452 @@
|
||||
#include <Resource_Manager.hxx>
|
||||
#include <Resource_Manager.ixx>
|
||||
#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
|
||||
#include <Resource_QuickSortOfArray1.hxx>
|
||||
#include <Resource_LexicalCompare.hxx>
|
||||
|
||||
#include <OSD_Path.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <Resource_Unicode.hxx>
|
||||
#include <TColStd_Array1OfAsciiString.hxx>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#define END 0
|
||||
#define EMPTY 1
|
||||
#define COMMENT 2
|
||||
#define INCLUDE 3
|
||||
#define RESOURCE 4
|
||||
#define ERROR -1
|
||||
|
||||
static Standard_Integer WhatKindOfLine(OSD_File& aFile,
|
||||
TCollection_AsciiString& aToken1,
|
||||
TCollection_AsciiString& aToken2);
|
||||
|
||||
static Standard_Integer GetLine(OSD_File& aFile,TCollection_AsciiString& aLine);
|
||||
|
||||
static Standard_Boolean Debug;
|
||||
|
||||
Resource_Manager::Resource_Manager(const Standard_CString aName,
|
||||
TCollection_AsciiString& aDefaultsDirectory,
|
||||
TCollection_AsciiString& anUserDefaultsDirectory,
|
||||
const Standard_Boolean Verbose) : myName(aName), myVerbose(Verbose)
|
||||
{
|
||||
if ( !aDefaultsDirectory.IsEmpty() ) {
|
||||
Load(aDefaultsDirectory,myName,myRefMap);
|
||||
}
|
||||
else
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager Warning: aDefaultsDirectory is empty." << endl;
|
||||
|
||||
if ( !anUserDefaultsDirectory.IsEmpty() ) {
|
||||
Load(anUserDefaultsDirectory,myName,myRefMap);
|
||||
}
|
||||
else
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager Warning: anUserDefaultsDirectory is empty." << endl;
|
||||
}
|
||||
|
||||
Resource_Manager::Resource_Manager(const Standard_CString aName,
|
||||
const Standard_Boolean Verbose) : myName(aName), myVerbose(Verbose)
|
||||
{
|
||||
Debug = (getenv("ResourceDebug") != NULL) ;
|
||||
|
||||
TCollection_AsciiString EnvVar, CSF_ = "CSF_" ;
|
||||
TCollection_AsciiString Directory ;
|
||||
Standard_CString dir ;
|
||||
|
||||
if ( getenv ("CSF_ResourceVerbose") != NULL )
|
||||
myVerbose = Standard_True;
|
||||
|
||||
EnvVar = CSF_ + aName + "Defaults" ;
|
||||
if ((dir = getenv (EnvVar.ToCString())) != NULL) {
|
||||
Directory = dir;
|
||||
Load(Directory,myName,myRefMap);
|
||||
}
|
||||
else
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager Warning: Environment variable \"" << EnvVar
|
||||
<< "\" not set." << endl;
|
||||
|
||||
EnvVar = CSF_ + aName + "UserDefaults" ;
|
||||
if ((dir = getenv (EnvVar.ToCString())) != NULL) {
|
||||
Directory = dir;
|
||||
Load(Directory, myName, myUserMap);
|
||||
}
|
||||
else
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager Warning: Environment variable \"" << EnvVar
|
||||
<< "\" not set." << endl;
|
||||
}
|
||||
|
||||
void Resource_Manager::Load(TCollection_AsciiString& aDirectory,
|
||||
TCollection_AsciiString& aName,
|
||||
Resource_DataMapOfAsciiStringAsciiString& aMap)
|
||||
{
|
||||
Standard_Integer Kind, Pos;
|
||||
TCollection_AsciiString Token1, Token2;
|
||||
TCollection_AsciiString Directory, Name;
|
||||
TCollection_AsciiString FileName;
|
||||
FileName = aDirectory + "/" + aName;
|
||||
OSD_File File = OSD_Path(FileName);
|
||||
File.Open(OSD_ReadOnly,OSD_Protection());
|
||||
if (File.Failed()) {
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager Warning: Cannot read file \"" << FileName
|
||||
<< "\". File not found or permission denied." << endl;
|
||||
return;
|
||||
}
|
||||
Standard_Integer LineNumber = 1;
|
||||
while ((Kind = WhatKindOfLine(File, Token1, Token2)) != END) {
|
||||
switch (Kind) {
|
||||
case COMMENT :
|
||||
case EMPTY :
|
||||
break ;
|
||||
case INCLUDE :
|
||||
Directory = OSD_Path::AbsolutePath(aDirectory,Token1);
|
||||
Pos = Directory.SearchFromEnd("/");
|
||||
if (Pos != 0) {
|
||||
Name = Directory.Split(Pos);
|
||||
Directory.Trunc(Pos-1);
|
||||
Load(Directory,Name,aMap);
|
||||
}
|
||||
break;
|
||||
case RESOURCE :
|
||||
if (!aMap.Bind(Token1,Token2))
|
||||
aMap(Token1) = Token2;
|
||||
break;
|
||||
case ERROR :
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager: Syntax error at line "
|
||||
<< LineNumber << " in file : " << FileName << endl;
|
||||
break;
|
||||
}
|
||||
LineNumber++;
|
||||
}
|
||||
File.Close();
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager: " << ((&aMap == &myUserMap) ? "User" : "Reference")
|
||||
<< " file \"" << FileName << "\" loaded" << endl;
|
||||
}
|
||||
|
||||
static Standard_Integer WhatKindOfLine(OSD_File& aFile,
|
||||
TCollection_AsciiString& aToken1,
|
||||
TCollection_AsciiString& aToken2)
|
||||
{
|
||||
TCollection_AsciiString WhiteSpace = " \t" ;
|
||||
Standard_Integer Pos1,Pos2,Pos ;
|
||||
TCollection_AsciiString Line ;
|
||||
|
||||
if (!GetLine(aFile,Line))
|
||||
return END;
|
||||
|
||||
if (Line.Value(1) == '!')
|
||||
return COMMENT;
|
||||
|
||||
if (Line.Value(1) == '#') {
|
||||
Line.Remove(1);
|
||||
if ((Line.Token(" \t")).IsDifferent("include"))
|
||||
return ERROR;
|
||||
|
||||
aToken1 = Line.Token(" \t\n",2);
|
||||
return INCLUDE;
|
||||
}
|
||||
|
||||
Pos1 = Line.FirstLocationNotInSet(WhiteSpace, 1, Line.Length());
|
||||
if (Line.Value(Pos1) == '\n')
|
||||
return EMPTY;
|
||||
|
||||
Pos2 = Line.Location(1,':',Pos1,Line.Length());
|
||||
if (!Pos2 || Pos1 == Pos2)
|
||||
return ERROR;
|
||||
|
||||
for (Pos = Pos2-1; Line.Value(Pos) == '\t' || Line.Value(Pos) == ' ' ; Pos--);
|
||||
aToken1 = Line.SubString(Pos1, Pos);
|
||||
|
||||
if (Debug)
|
||||
cout << "Key = '" << aToken1 << flush ;
|
||||
|
||||
if ((Pos = Line.FirstLocationNotInSet(WhiteSpace, Pos2+1, Line.Length()))) {
|
||||
if (Line.Value(Pos) == '\\')
|
||||
switch(Line.Value(Pos+1)) {
|
||||
case '\\' :
|
||||
case ' ' :
|
||||
case '\t' :
|
||||
Pos++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Pos == Line.Length())
|
||||
aToken2.Clear();
|
||||
else
|
||||
aToken2 = Line.SubString(Pos,Line.Length()-1);
|
||||
|
||||
if (Debug)
|
||||
cout << "'\t Value = '" << aToken2 << "'" << endl << flush;
|
||||
return RESOURCE;
|
||||
}
|
||||
|
||||
// Retourne 0 (EOF) ou une ligne toujours terminee par <NL>.
|
||||
|
||||
static Standard_Integer GetLine(OSD_File& aFile,TCollection_AsciiString& aLine)
|
||||
{
|
||||
TCollection_AsciiString Buffer;
|
||||
Standard_Integer BufSize = 10;
|
||||
Standard_Integer Len;
|
||||
|
||||
aLine.Clear();
|
||||
do {
|
||||
aFile.ReadLine(Buffer,BufSize,Len);
|
||||
aLine += Buffer;
|
||||
if (aFile.IsAtEnd())
|
||||
if (!aLine.Length()) return 0;
|
||||
else aLine += "\n";
|
||||
} while (aLine.Value(aLine.Length()) != '\n');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Save
|
||||
//purpose : Sort and save the user resources in the user file.
|
||||
// Creates the file if it does not exist.
|
||||
//=======================================================================
|
||||
Standard_Boolean Resource_Manager::Save() const
|
||||
{
|
||||
Standard_Integer Index;
|
||||
TCollection_AsciiString EnvVar, CSF_ = "CSF_";
|
||||
Standard_CString dir;
|
||||
|
||||
EnvVar = CSF_ + myName + "UserDefaults";
|
||||
|
||||
if ((dir = getenv (EnvVar.ToCString())) == NULL) {
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager Warning: environment variable \""
|
||||
<< EnvVar << "\" not set. Cannot save resources." << endl ;
|
||||
return Standard_False;
|
||||
}
|
||||
TCollection_AsciiString FilePath = dir;
|
||||
OSD_Directory Dir = OSD_Path(FilePath);
|
||||
Standard_Boolean Status = Standard_True;
|
||||
if ( !Dir.Exists() ) {
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
Dir.Build(OSD_Protection(OSD_RX, OSD_RWX, OSD_RX, OSD_RX));
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Status = Standard_False;
|
||||
}
|
||||
}
|
||||
Status = Status && !Dir.Failed();
|
||||
if (!Status) {
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager: Error opening or creating directory \"" << FilePath
|
||||
<< "\". Permission denied. Cannot save resources." << endl;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
FilePath += "/"; FilePath += myName;
|
||||
OSD_Path Path(FilePath);
|
||||
OSD_File File = Path;
|
||||
OSD_Protection theProt;
|
||||
Status = Standard_True;
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
File.Build(OSD_ReadWrite, theProt);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Status = Standard_False;
|
||||
}
|
||||
}
|
||||
Status = Status && !File.Failed();
|
||||
if (!Status) {
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager: Error opening or creating file \"" << FilePath
|
||||
<< "\". Permission denied. Cannot save resources." << endl;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Resource_LexicalCompare Comp;
|
||||
Standard_Integer NbKey = myUserMap.Extent();
|
||||
TColStd_Array1OfAsciiString KeyArray(1,NbKey);
|
||||
Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString Iter(myUserMap);
|
||||
|
||||
for ( Index = 1; Iter.More(); Iter.Next())
|
||||
KeyArray(Index++)= Iter.Key();
|
||||
|
||||
Resource_QuickSortOfArray1::Sort(KeyArray, Comp);
|
||||
|
||||
TCollection_AsciiString Line, Value;
|
||||
for (Index = 1 ; Index <= NbKey ; Index++) {
|
||||
Value = myUserMap(KeyArray(Index));
|
||||
if (!Value.IsEmpty())
|
||||
switch(Value.Value(1)) {
|
||||
case '\\' :
|
||||
case ' ' :
|
||||
case '\t' :
|
||||
Value.Insert(1,'\\');
|
||||
break;
|
||||
}
|
||||
Line = KeyArray(Index) + ":\t" + Value + "\n";
|
||||
|
||||
if (Debug)
|
||||
cout << "Line = '" << Line << "'" << endl;
|
||||
|
||||
File.Write(Line, Line.Length());
|
||||
}
|
||||
if (myVerbose)
|
||||
cout << "Resource Manager: Resources saved in file " << FilePath << endl;
|
||||
File.Close();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Integer
|
||||
//purpose : Gets the value of an integer resource
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer Resource_Manager::Integer(const Standard_CString aResourceName) const
|
||||
{
|
||||
TCollection_AsciiString Result = Value(aResourceName) ;
|
||||
if (!Result.IsIntegerValue()) {
|
||||
TCollection_AsciiString n("Value of resource `");
|
||||
n+= aResourceName;
|
||||
n+= "` is not an integer";
|
||||
Standard_TypeMismatch::Raise(n.ToCString());
|
||||
}
|
||||
return Result.IntegerValue();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Real
|
||||
//purpose : Gets the value of a real resource
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real Resource_Manager::Real(const Standard_CString aResourceName) const
|
||||
{
|
||||
TCollection_AsciiString Result = Value(aResourceName) ;
|
||||
if (!Result.IsRealValue()) {
|
||||
TCollection_AsciiString n("Value of resource `");
|
||||
n+= aResourceName;
|
||||
n+= "` is not a real";
|
||||
Standard_TypeMismatch::Raise(n.ToCString());
|
||||
}
|
||||
return Result.RealValue();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose : Gets the value of a CString resource
|
||||
//=======================================================================
|
||||
|
||||
Standard_CString Resource_Manager::Value(const Standard_CString aResource) const
|
||||
{
|
||||
TCollection_AsciiString Resource(aResource);
|
||||
if (myUserMap.IsBound(Resource))
|
||||
return myUserMap(Resource).ToCString();
|
||||
if (myRefMap.IsBound(Resource))
|
||||
return myRefMap(Resource).ToCString();
|
||||
Resource_NoSuchResource::Raise(aResource);
|
||||
return ("");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ExtValue
|
||||
//purpose : Gets the value of a ExtString resource
|
||||
//=======================================================================
|
||||
|
||||
Standard_ExtString Resource_Manager::ExtValue(const Standard_CString aResource)
|
||||
{
|
||||
TCollection_AsciiString Resource(aResource);
|
||||
if (myExtStrMap.IsBound(Resource))
|
||||
return myExtStrMap(Resource).ToExtString();
|
||||
|
||||
TCollection_AsciiString Result = Value(aResource);
|
||||
TCollection_ExtendedString ExtResult;
|
||||
|
||||
Resource_Unicode::ConvertFormatToUnicode(Result.ToCString(),ExtResult);
|
||||
|
||||
myExtStrMap.Bind(Resource, ExtResult);
|
||||
return myExtStrMap(Resource).ToExtString();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetResource
|
||||
//purpose : Sets the new value of an integer resource.
|
||||
// If the resource does not exist, it is created.
|
||||
//=======================================================================
|
||||
void Resource_Manager::SetResource(const Standard_CString aResourceName,
|
||||
const Standard_Integer aValue)
|
||||
{
|
||||
SetResource(aResourceName,TCollection_AsciiString(aValue).ToCString());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetResource
|
||||
//purpose : Sets the new value of a real resource.
|
||||
// If the resource does not exist, it is created.
|
||||
//=======================================================================
|
||||
void Resource_Manager::SetResource(const Standard_CString aResourceName,
|
||||
const Standard_Real aValue)
|
||||
{
|
||||
SetResource(aResourceName,TCollection_AsciiString(aValue).ToCString());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetResource
|
||||
//purpose : Sets the new value of ExtString resource.
|
||||
// If the resource does not exist, it is created.
|
||||
//=======================================================================
|
||||
void Resource_Manager::SetResource(const Standard_CString aResource,
|
||||
const Standard_ExtString aValue)
|
||||
{
|
||||
Standard_PCharacter pStr;
|
||||
TCollection_AsciiString Resource = aResource;
|
||||
TCollection_ExtendedString ExtValue = aValue;
|
||||
TCollection_AsciiString FormatStr(ExtValue.Length()*3+10, ' ');
|
||||
|
||||
if (!myExtStrMap.Bind(Resource,ExtValue)) {
|
||||
myExtStrMap(Resource) = ExtValue;
|
||||
}
|
||||
//
|
||||
pStr=(Standard_PCharacter)FormatStr.ToCString();
|
||||
//
|
||||
Resource_Unicode::ConvertUnicodeToFormat(ExtValue,
|
||||
pStr,//FormatStr.ToCString(),
|
||||
FormatStr.Length()) ;
|
||||
SetResource(aResource,FormatStr.ToCString());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetResource
|
||||
//purpose : Sets the new value of an enum resource.
|
||||
// If the resource does not exist, it is created.
|
||||
//=======================================================================
|
||||
void Resource_Manager::SetResource(const Standard_CString aResource,
|
||||
const Standard_CString aValue)
|
||||
{
|
||||
TCollection_AsciiString Resource = aResource;
|
||||
TCollection_AsciiString Value = aValue;
|
||||
if (!myUserMap.Bind(Resource, Value))
|
||||
myUserMap(Resource) = Value;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Find
|
||||
//purpose : Tells if a resource exits.
|
||||
//=======================================================================
|
||||
Standard_Boolean Resource_Manager::Find(const Standard_CString aResource) const
|
||||
{
|
||||
TCollection_AsciiString Resource(aResource);
|
||||
if (myUserMap.IsBound(Resource) || myRefMap.IsBound(Resource))
|
||||
return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
32799
src/Resource/Resource_Shiftjis.h
Executable file
32799
src/Resource/Resource_Shiftjis.h
Executable file
File diff suppressed because it is too large
Load Diff
137
src/Resource/Resource_Unicode.cdl
Executable file
137
src/Resource/Resource_Unicode.cdl
Executable file
@@ -0,0 +1,137 @@
|
||||
-- File: Resource_Unicode.cdl
|
||||
-- Created: Thu Sep 26 14:30:43 1996
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@legox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
|
||||
class Unicode from Resource
|
||||
|
||||
---Purpose: This class provides functions used to convert a non-ASCII C string
|
||||
-- given in ANSI, EUC, GB or SJIS format, to a
|
||||
-- Unicode string of extended characters, and vice versa.
|
||||
|
||||
uses ExtendedString from TCollection,
|
||||
FormatType from Resource
|
||||
|
||||
is
|
||||
|
||||
ConvertSJISToUnicode(myclass;
|
||||
fromstr : CString;
|
||||
tostr : out ExtendedString);
|
||||
---Purpose: Converts non-ASCII CString <fromstr> in SJIS format
|
||||
-- to Unicode ExtendedString <tostr>.
|
||||
|
||||
|
||||
ConvertEUCToUnicode(myclass;
|
||||
fromstr : CString;
|
||||
tostr : out ExtendedString);
|
||||
---Purpose: Converts non-ASCII CString <fromstr> in EUC format
|
||||
-- to Unicode ExtendedString <tostr>.
|
||||
|
||||
ConvertGBToUnicode(myclass;
|
||||
fromstr : CString;
|
||||
tostr : out ExtendedString);
|
||||
---Purpose: Converts non-ASCII CString <fromstr> in GB format
|
||||
-- to Unicode ExtendedString <tostr>.
|
||||
|
||||
ConvertANSIToUnicode(myclass;
|
||||
fromstr : CString;
|
||||
tostr : out ExtendedString);
|
||||
---Purpose: Converts non-ASCII CString <fromstr> in ANSI format
|
||||
-- to Unicode ExtendedString <tostr>.
|
||||
|
||||
|
||||
|
||||
ConvertUnicodeToSJIS(myclass;
|
||||
fromstr : ExtendedString;
|
||||
tostr :out PCharacter;
|
||||
maxsize : Integer)
|
||||
---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
|
||||
-- CString <tostr> in SJIS format, limited to <maxsize>
|
||||
-- characters. To translate the whole <fromstr>, use more
|
||||
-- than twice the length of <fromstr>. Returns true if
|
||||
-- <maxsize> has not been reached before end of conversion.
|
||||
returns Boolean;
|
||||
|
||||
ConvertUnicodeToEUC(myclass;
|
||||
fromstr : ExtendedString;
|
||||
tostr : out PCharacter;
|
||||
maxsize : Integer)
|
||||
---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
|
||||
-- CString <tostr> in EUC format, limited to <maxsize>
|
||||
-- characters. To translate the whole <fromstr>, use more
|
||||
-- than twice the length of <fromstr>. Returns true if
|
||||
-- <maxsize> has not been reached before end of conversion.
|
||||
returns Boolean;
|
||||
|
||||
|
||||
ConvertUnicodeToGB(myclass;
|
||||
fromstr : ExtendedString;
|
||||
tostr : out PCharacter;
|
||||
maxsize : Integer)
|
||||
---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
|
||||
-- CString <tostr> in GB format, limited to <maxsize>
|
||||
-- characters. To translate the whole <fromstr>, use more
|
||||
-- than twice the length of <fromstr>. Returns true if
|
||||
-- <maxsize> has not been reached before end of conversion.
|
||||
returns Boolean;
|
||||
|
||||
|
||||
ConvertUnicodeToANSI(myclass;
|
||||
fromstr : ExtendedString;
|
||||
tostr : out PCharacter;
|
||||
maxsize : Integer)
|
||||
---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
|
||||
-- CString <tostr> in ANSI format, limited to <maxsize>
|
||||
-- characters. To translate the whole <fromstr>, use more
|
||||
-- than twice the length of <fromstr>. Returns true if
|
||||
-- <maxsize> has not been reached before end of conversion.
|
||||
returns Boolean;
|
||||
|
||||
|
||||
SetFormat(myclass; typecode : FormatType from Resource);
|
||||
---Purpose: Defines the current conversion format as typecode.
|
||||
-- This conversion format will then be used by the
|
||||
-- functions ConvertFormatToUnicode and
|
||||
-- ConvertUnicodeToFormat to convert the strings.
|
||||
|
||||
GetFormat(myclass)
|
||||
---Purpose: Returns the current conversion format (either
|
||||
-- ANSI, EUC, GB or SJIS).
|
||||
-- The current converting format must be defined in
|
||||
-- advance with the SetFormat function.
|
||||
returns FormatType from Resource;
|
||||
|
||||
|
||||
ReadFormat(myclass);
|
||||
---Purpose: Reads converting format from resource "FormatType"
|
||||
-- in Resource Manager "CharSet"
|
||||
|
||||
ConvertFormatToUnicode(myclass;
|
||||
fromstr : CString;
|
||||
tostr : out ExtendedString);
|
||||
---Purpose: Converts the non-ASCII C string fromstr to the
|
||||
-- Unicode string of extended characters tostr.
|
||||
-- fromstr is translated according to the format
|
||||
-- (either ANSI, EUC, GB or SJIS) returned by the function GetFormat.
|
||||
|
||||
ConvertUnicodeToFormat(myclass;
|
||||
fromstr : ExtendedString;
|
||||
tostr : out PCharacter;
|
||||
maxsize : Integer)
|
||||
---Purpose: Converts the Unicode string of extended
|
||||
-- characters fromstr to the non-ASCII C string
|
||||
-- tostr according to the format (either ANSI, EUC,
|
||||
-- GB or SJIS) returned by the function GetFormat.
|
||||
-- maxsize limits the size of the string tostr to a
|
||||
-- maximum number of characters. You need more
|
||||
-- than twice the length of the string fromstr to
|
||||
-- complete the conversion.
|
||||
-- The function returns true if conversion is
|
||||
-- complete, i.e. the maximum number of characters
|
||||
-- maxsize is not reached by tostr before the end
|
||||
-- of conversion of fromstr.
|
||||
returns Boolean;
|
||||
|
||||
end Unicode;
|
411
src/Resource/Resource_Unicode.cxx
Executable file
411
src/Resource/Resource_Unicode.cxx
Executable file
@@ -0,0 +1,411 @@
|
||||
// Copyright: Matra-Datavision 1996
|
||||
// File: Resource_Unicode.cxx
|
||||
// Created: Thu Sep 26 14:39:46 1996
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <Resource_Unicode.ixx>
|
||||
#include <Resource_ConvertUnicode.hxx>
|
||||
#include <Resource_Manager.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#define isjis(c) (((c)>=0x21 && (c)<=0x7e))
|
||||
#define iseuc(c) (((c)>=0xa1 && (c)<=0xfe))
|
||||
#define issjis1(c) (((c)>=0x81 && (c)<=0x9f) || ((c)>=0xe0 && (c)<=0xef))
|
||||
|
||||
#define issjis2(c) ((c)>=0x40 && (c)<=0xfc && (c)!=0x7f)
|
||||
|
||||
#define ishankana(c) ((c)>=0xa0 && (c)<=0xdf)
|
||||
|
||||
static inline Standard_Boolean isshift (unsigned char c) { return c >= 0x80; }
|
||||
static inline Standard_Boolean isshift (unsigned int c) { return c >= 0x80 && c <= 0xff; }
|
||||
|
||||
void Resource_Unicode::ConvertSJISToUnicode(const Standard_CString fromstr,TCollection_ExtendedString& tostr)
|
||||
{
|
||||
tostr.Clear();
|
||||
|
||||
unsigned char* currentstr = ((unsigned char*) fromstr);
|
||||
unsigned int pl,ph;
|
||||
// BIG INDIAN USED HERE
|
||||
while(*currentstr != '\0') {
|
||||
if (issjis1(*currentstr)) {
|
||||
|
||||
ph = ((unsigned int) *currentstr);
|
||||
// Be Carefull with first and second !!
|
||||
|
||||
currentstr++;
|
||||
|
||||
pl = ((unsigned int) *currentstr);
|
||||
currentstr++;
|
||||
|
||||
Resource_sjis_to_unicode(&ph,&pl);
|
||||
Standard_ExtCharacter curcar = ((Standard_ExtCharacter) ((ph << 8) | pl));
|
||||
TCollection_ExtendedString curext(curcar);
|
||||
tostr.AssignCat(curext);
|
||||
}
|
||||
else {
|
||||
TCollection_ExtendedString curext(((char) *currentstr));
|
||||
currentstr++;
|
||||
tostr.AssignCat(curext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Resource_Unicode::ConvertEUCToUnicode(const Standard_CString fromstr,TCollection_ExtendedString& tostr)
|
||||
{
|
||||
tostr.Clear();
|
||||
|
||||
unsigned char* currentstr = ((unsigned char*) fromstr);
|
||||
unsigned int pl,ph;
|
||||
// BIG INDIAN USED HERE
|
||||
while(*currentstr != '\0') {
|
||||
if (iseuc(*currentstr)) {
|
||||
|
||||
ph = ((unsigned int) *currentstr);
|
||||
// Be Carefull with first and second !!
|
||||
|
||||
currentstr++;
|
||||
|
||||
pl = ((unsigned int) *currentstr);
|
||||
currentstr++;
|
||||
|
||||
Resource_euc_to_unicode(&ph,&pl);
|
||||
Standard_ExtCharacter curcar = ((Standard_ExtCharacter) ((ph << 8) | pl));
|
||||
TCollection_ExtendedString curext(curcar);
|
||||
tostr.AssignCat(curext);
|
||||
}
|
||||
else {
|
||||
TCollection_ExtendedString curext(((char) *currentstr));
|
||||
currentstr++;
|
||||
tostr.AssignCat(curext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Resource_Unicode::ConvertGBToUnicode(const Standard_CString fromstr,TCollection_ExtendedString& tostr)
|
||||
{
|
||||
tostr.Clear();
|
||||
|
||||
unsigned char* currentstr = ((unsigned char*) fromstr);
|
||||
unsigned int pl,ph;
|
||||
// BIG INDIAN USED HERE
|
||||
while(*currentstr != '\0') {
|
||||
if (isshift(*currentstr)) {
|
||||
|
||||
ph = ((unsigned int) *currentstr);
|
||||
// Be Carefull with first and second !!
|
||||
|
||||
currentstr++;
|
||||
|
||||
pl = ((unsigned int) *currentstr);
|
||||
currentstr++;
|
||||
|
||||
Resource_gb_to_unicode(&ph,&pl);
|
||||
Standard_ExtCharacter curcar = ((Standard_ExtCharacter) ((ph << 8) | pl));
|
||||
TCollection_ExtendedString curext(curcar);
|
||||
tostr.AssignCat(curext);
|
||||
}
|
||||
else {
|
||||
TCollection_ExtendedString curext(((char) *currentstr));
|
||||
currentstr++;
|
||||
tostr.AssignCat(curext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Resource_Unicode::ConvertANSIToUnicode(const Standard_CString fromstr,TCollection_ExtendedString& tostr)
|
||||
{
|
||||
tostr.Clear();
|
||||
|
||||
TCollection_ExtendedString curext(fromstr);
|
||||
tostr.AssignCat(curext);
|
||||
}
|
||||
|
||||
Standard_Boolean Resource_Unicode::ConvertUnicodeToSJIS(const TCollection_ExtendedString& fromstr,
|
||||
Standard_PCharacter& tostr,
|
||||
const Standard_Integer maxsize)
|
||||
{
|
||||
Standard_Integer nbtrans = 0;
|
||||
Standard_Integer nbext = 1;
|
||||
Standard_Boolean finished = Standard_False;
|
||||
Standard_ExtCharacter curcar;
|
||||
unsigned int pl,ph;
|
||||
// BIG INDIAN USED HERE
|
||||
|
||||
while (!finished) {
|
||||
if (nbext > fromstr.Length()) {
|
||||
finished = Standard_True;
|
||||
tostr[nbtrans] = '\0';
|
||||
}
|
||||
else {
|
||||
curcar = fromstr.Value(nbext);
|
||||
nbext++;
|
||||
ph = (((unsigned int) curcar) >> 8) & 0xFF;
|
||||
pl = ((unsigned int) curcar) & 0xFF;
|
||||
Resource_unicode_to_sjis(&ph,&pl);
|
||||
if (issjis1(ph)) {
|
||||
if (nbtrans < (maxsize-3)) {
|
||||
tostr[nbtrans] = ((char) ph);
|
||||
nbtrans++;
|
||||
tostr[nbtrans] = ((char) pl);
|
||||
nbtrans++;
|
||||
}
|
||||
else {
|
||||
tostr[nbtrans] = '\0';
|
||||
nbtrans = maxsize-1;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tostr[nbtrans] = ((char) pl);
|
||||
nbtrans++;
|
||||
}
|
||||
if (nbtrans >= (maxsize - 1)) {
|
||||
tostr[maxsize-1] = '\0';
|
||||
finished = Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean Resource_Unicode::ConvertUnicodeToEUC(const TCollection_ExtendedString& fromstr,
|
||||
Standard_PCharacter& tostr,
|
||||
const Standard_Integer maxsize)
|
||||
{
|
||||
Standard_Integer nbtrans = 0;
|
||||
Standard_Integer nbext = 1;
|
||||
Standard_Boolean finished = Standard_False;
|
||||
Standard_ExtCharacter curcar;
|
||||
unsigned int pl,ph;
|
||||
// BIG INDIAN USED HERE
|
||||
|
||||
while (!finished) {
|
||||
if (nbext > fromstr.Length()) {
|
||||
finished = Standard_True;
|
||||
tostr[nbtrans] = '\0';
|
||||
}
|
||||
else {
|
||||
curcar = fromstr.Value(nbext);
|
||||
nbext++;
|
||||
ph = (((unsigned int) curcar) >> 8) & 0xFF;
|
||||
pl = ((unsigned int) curcar) & 0xFF;
|
||||
Resource_unicode_to_euc(&ph,&pl);
|
||||
if (iseuc(ph)) {
|
||||
if (nbtrans < (maxsize-3)) {
|
||||
tostr[nbtrans] = ((char) ph);
|
||||
nbtrans++;
|
||||
tostr[nbtrans] = ((char) pl);
|
||||
nbtrans++;
|
||||
}
|
||||
else {
|
||||
tostr[nbtrans-1] = '\0';
|
||||
nbtrans = maxsize-1;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tostr[nbtrans] = ((char) pl);
|
||||
nbtrans++;
|
||||
}
|
||||
if (nbtrans >= (maxsize - 1)) {
|
||||
tostr[maxsize-1] = '\0';
|
||||
finished = Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean Resource_Unicode::ConvertUnicodeToGB(const TCollection_ExtendedString& fromstr,
|
||||
Standard_PCharacter& tostr,
|
||||
const Standard_Integer maxsize)
|
||||
{
|
||||
Standard_Integer nbtrans = 0;
|
||||
Standard_Integer nbext = 1;
|
||||
Standard_Boolean finished = Standard_False;
|
||||
Standard_ExtCharacter curcar;
|
||||
unsigned int pl,ph;
|
||||
// BIG INDIAN USED HERE
|
||||
|
||||
while (!finished) {
|
||||
if (nbext > fromstr.Length()) {
|
||||
finished = Standard_True;
|
||||
tostr[nbtrans] = '\0';
|
||||
}
|
||||
else {
|
||||
curcar = fromstr.Value(nbext);
|
||||
nbext++;
|
||||
ph = (((unsigned int) curcar) >> 8) & 0xFF;
|
||||
pl = ((unsigned int) curcar) & 0xFF;
|
||||
Resource_unicode_to_gb(&ph,&pl);
|
||||
if (isshift(ph)) {
|
||||
if (nbtrans < (maxsize-3)) {
|
||||
tostr[nbtrans] = ((char) ph);
|
||||
nbtrans++;
|
||||
tostr[nbtrans] = ((char) pl);
|
||||
nbtrans++;
|
||||
}
|
||||
else {
|
||||
tostr[nbtrans-1] = '\0';
|
||||
nbtrans = maxsize-1;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tostr[nbtrans] = ((char) curcar) & 0xFF;
|
||||
nbtrans++;
|
||||
}
|
||||
if (nbtrans >= (maxsize - 1)) {
|
||||
tostr[maxsize-1] = '\0';
|
||||
finished = Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean Resource_Unicode::ConvertUnicodeToANSI(const TCollection_ExtendedString& fromstr,
|
||||
Standard_PCharacter& tostr,
|
||||
const Standard_Integer maxsize)
|
||||
{
|
||||
Standard_Integer nbtrans = 0;
|
||||
Standard_Integer nbext = 1;
|
||||
Standard_Boolean finished = Standard_False;
|
||||
Standard_ExtCharacter curcar;
|
||||
unsigned int pl,ph;
|
||||
// BIG INDIAN USED HERE
|
||||
|
||||
while (!finished) {
|
||||
if (nbext > fromstr.Length()) {
|
||||
finished = Standard_True;
|
||||
tostr[nbtrans] = '\0';
|
||||
}
|
||||
else {
|
||||
curcar = fromstr.Value(nbext);
|
||||
nbext++;
|
||||
ph = ((unsigned int) curcar) >> 8;
|
||||
pl = ((unsigned int) curcar) & 0xFF;
|
||||
if (ph == 0) {
|
||||
tostr[nbtrans] = ((char) pl);
|
||||
}
|
||||
else {
|
||||
tostr[nbtrans] = ' ';
|
||||
}
|
||||
nbtrans++;
|
||||
}
|
||||
if (nbtrans >= (maxsize - 1)) {
|
||||
tostr[maxsize-1] = '\0';
|
||||
finished = Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
static Standard_Boolean AlreadyRead = Standard_False;
|
||||
|
||||
static Resource_FormatType& Resource_Current_Format()
|
||||
{
|
||||
static Resource_FormatType theformat = Resource_ANSI;
|
||||
if (!AlreadyRead) {
|
||||
AlreadyRead = Standard_True ;
|
||||
Handle(Resource_Manager) mgr = new Resource_Manager("CharSet");
|
||||
if (mgr->Find("FormatType")) {
|
||||
TCollection_AsciiString form = mgr->Value("FormatType");
|
||||
if (form.IsEqual("SJIS")) {
|
||||
theformat = Resource_SJIS;
|
||||
}
|
||||
else if (form.IsEqual("EUC")) {
|
||||
theformat = Resource_EUC;
|
||||
}
|
||||
else if (form.IsEqual("GB")) {
|
||||
theformat = Resource_GB;
|
||||
}
|
||||
else {
|
||||
theformat = Resource_ANSI;
|
||||
}
|
||||
}
|
||||
else {
|
||||
theformat = Resource_ANSI;
|
||||
}
|
||||
}
|
||||
return theformat;
|
||||
}
|
||||
|
||||
void Resource_Unicode::SetFormat(const Resource_FormatType typecode)
|
||||
{
|
||||
AlreadyRead = Standard_True;
|
||||
Resource_Current_Format() = typecode;
|
||||
}
|
||||
|
||||
Resource_FormatType Resource_Unicode::GetFormat()
|
||||
{
|
||||
return Resource_Current_Format();
|
||||
}
|
||||
|
||||
|
||||
void Resource_Unicode::ReadFormat()
|
||||
{
|
||||
AlreadyRead = Standard_False;
|
||||
Resource_Unicode::GetFormat();
|
||||
}
|
||||
|
||||
void Resource_Unicode::ConvertFormatToUnicode(const Standard_CString fromstr,
|
||||
TCollection_ExtendedString& tostr)
|
||||
{
|
||||
Resource_FormatType theform = Resource_Unicode::GetFormat();
|
||||
switch (theform) {
|
||||
case Resource_SJIS :
|
||||
{
|
||||
ConvertSJISToUnicode(fromstr,tostr);
|
||||
break;
|
||||
}
|
||||
case Resource_EUC :
|
||||
{
|
||||
ConvertEUCToUnicode(fromstr,tostr);
|
||||
break;
|
||||
}
|
||||
case Resource_GB :
|
||||
{
|
||||
ConvertGBToUnicode(fromstr,tostr);
|
||||
break;
|
||||
}
|
||||
case Resource_ANSI :
|
||||
{
|
||||
ConvertANSIToUnicode(fromstr,tostr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Boolean Resource_Unicode::ConvertUnicodeToFormat(const TCollection_ExtendedString& fromstr,
|
||||
Standard_PCharacter& tostr,
|
||||
const Standard_Integer maxsize)
|
||||
{
|
||||
Resource_FormatType theform = Resource_Unicode::GetFormat();
|
||||
switch (theform) {
|
||||
case Resource_SJIS :
|
||||
{
|
||||
return ConvertUnicodeToSJIS(fromstr,tostr,maxsize);
|
||||
}
|
||||
case Resource_EUC :
|
||||
{
|
||||
return ConvertUnicodeToEUC(fromstr,tostr,maxsize);
|
||||
}
|
||||
case Resource_GB :
|
||||
{
|
||||
return ConvertUnicodeToGB(fromstr,tostr,maxsize);
|
||||
}
|
||||
case Resource_ANSI :
|
||||
{
|
||||
return ConvertUnicodeToANSI(fromstr,tostr,maxsize);
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
32772
src/Resource/Resource_gb2312.h
Executable file
32772
src/Resource/Resource_gb2312.h
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user