Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d84344990
|
||
|
|
98ba7450a4
|
||
|
|
b82a36142c
|
||
|
|
d35854691c
|
+252
@@ -0,0 +1,252 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
AlignArrayOfStructures: Left
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: DontAlign
|
||||
AlignOperands: DontAlign
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: true
|
||||
BeforeWhile: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: AfterComma
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 150
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Left
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Leave
|
||||
EmptyLineBeforeAccessModifier: Leave
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: CurrentLine
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- forever
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^<Q.*'
|
||||
Priority: 200
|
||||
SortPriority: 200
|
||||
CaseSensitive: true
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: Indent
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 3
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 150
|
||||
PenaltyBreakBeforeFirstCallParameter: 300
|
||||
PenaltyBreakComment: 500
|
||||
PenaltyBreakFirstLessLess: 400
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 600
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 50
|
||||
PenaltyReturnTypeOnItsOwnLine: 300
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Middle
|
||||
PPIndentWidth: 1
|
||||
ReferenceAlignment: Middle
|
||||
ReflowComments: false
|
||||
RemoveBracesLLVM: false
|
||||
RequiresClausePosition: OwnLine
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: Custom
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: false
|
||||
AfterForeachMacros: false
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: false
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Custom
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InConditionalStatements: true
|
||||
InCStyleCasts: false
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInParentheses: true
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: c++20
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
- Q_CLASSINFO
|
||||
- Q_ENUM
|
||||
- Q_ENUM_NS
|
||||
- Q_FLAG
|
||||
- Q_FLAG_NS
|
||||
- Q_GADGET
|
||||
- Q_GADGET_EXPORT
|
||||
- Q_INTERFACES
|
||||
- Q_MOC_INCLUDE
|
||||
- Q_NAMESPACE
|
||||
- Q_NAMESPACE_EXPORT
|
||||
- Q_OBJECT
|
||||
- Q_PROPERTY
|
||||
- Q_REVISION
|
||||
- Q_DISABLE_COPY
|
||||
- Q_SET_OBJECT_NAME
|
||||
- QT_BEGIN_NAMESPACE
|
||||
- QT_END_NAMESPACE
|
||||
- QML_ADDED_IN_MINOR_VERSION
|
||||
- QML_ANONYMOUS
|
||||
- QML_ATTACHED
|
||||
- QML_DECLARE_TYPE
|
||||
- QML_DECLARE_TYPEINFO
|
||||
- QML_ELEMENT
|
||||
- QML_EXTENDED
|
||||
- QML_EXTENDED_NAMESPACE
|
||||
- QML_EXTRA_VERSION
|
||||
- QML_FOREIGN
|
||||
- QML_FOREIGN_NAMESPACE
|
||||
- QML_IMPLEMENTS_INTERFACES
|
||||
- QML_INTERFACE
|
||||
- QML_NAMED_ELEMENT
|
||||
- QML_REMOVED_IN_MINOR_VERSION
|
||||
- QML_SINGLETON
|
||||
- QML_UNAVAILABLE
|
||||
- QML_UNCREATABLE
|
||||
- QML_VALUE_TYPE
|
||||
TabWidth: 4
|
||||
UseCRLF: false
|
||||
UseTab: Always
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
CompileFlags:
|
||||
Add: [-pthread, -std=c++20, -I%%%CURRENT_DIR%%%/winixd, -I%%%GLOBAL_WORKING_DIR%%%/pikotools/src, -I%%%GLOBAL_WORKING_DIR%%%/ezc/src, -I%%%GLOBAL_WORKING_DIR%%%/morm/src, -I%%%GLOBAL_WORKING_DIR%%%/tito/src, -I/usr/include, -I/usr/local/include, -I/usr/local/include/postgresql, -DPT_HAS_MORM_LIBRARY, -DEZC_HAS_MORM_LIBRARY, -DMORM_HAS_EZC_LIBRARY]
|
||||
Add: [-pthread, -std=c++23, -I%%%CURRENT_DIR%%%/winixd, -I%%%GLOBAL_WORKING_DIR%%%/pikotools/src, -I%%%GLOBAL_WORKING_DIR%%%/ezc/src, -I%%%GLOBAL_WORKING_DIR%%%/morm/src, -I%%%GLOBAL_WORKING_DIR%%%/tito/src, -I/usr/include, -I/usr/local/include, -I/usr/local/include/postgresql, -DPT_HAS_MORM_LIBRARY, -DEZC_HAS_MORM_LIBRARY, -DMORM_HAS_EZC_LIBRARY]
|
||||
|
||||
@@ -1 +1 @@
|
||||
-std=c20
|
||||
-std=c23
|
||||
|
||||
@@ -1 +1 @@
|
||||
-std=c++20
|
||||
-std=c++23
|
||||
|
||||
@@ -5,6 +5,14 @@ GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..)
|
||||
|
||||
# ----------
|
||||
|
||||
has_force_arg=0
|
||||
|
||||
if [ $# -eq 1 ] ; then
|
||||
if [ $1 == 'force' ] ; then
|
||||
has_force_arg=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# make sure the current directory is correct
|
||||
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
|
||||
echo "this script should be called by make: make clangd (one level up)"
|
||||
@@ -17,7 +25,7 @@ GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
|
||||
|
||||
|
||||
if [ -f "${CURRENT_DIR}/.templates/.clangd" ] ; then
|
||||
if [ ! -f "${CURRENT_DIR}/.clangd" ] ; then
|
||||
if [ $has_force_arg -eq 1 -o ! -f "${CURRENT_DIR}/.clangd" ] ; then
|
||||
cat "${CURRENT_DIR}/.templates/.clangd" | \
|
||||
sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \
|
||||
-e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" > \
|
||||
|
||||
@@ -6,6 +6,14 @@ QTCREATOR_DIR=${CURRENT_DIR}/.qtcreator
|
||||
|
||||
# ----------
|
||||
|
||||
has_force_arg=0
|
||||
|
||||
if [ $# -eq 1 ] ; then
|
||||
if [ $1 == 'force' ] ; then
|
||||
has_force_arg=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# make sure the current directory is correct
|
||||
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
|
||||
echo "this script should be called by make: make qtcreator (one level up)"
|
||||
@@ -48,6 +56,10 @@ GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
|
||||
|
||||
was_qtcreator_dir=0
|
||||
|
||||
if [ $has_force_arg -eq 1 ] ; then
|
||||
rm -rf "${QTCREATOR_DIR}"
|
||||
fi
|
||||
|
||||
if [ -d "${QTCREATOR_DIR}" ] ; then
|
||||
was_qtcreator_dir=1
|
||||
else
|
||||
@@ -76,7 +88,7 @@ if [ -d "${QTCREATOR_DIR}" ] ; then
|
||||
|
||||
if [ $was_qtcreator_dir -eq 0 ] ; then
|
||||
echo "QTCreator files generated to ${QTCREATOR_DIR} directory"
|
||||
echo "select an 'open project...' option and find a ${QTCREATOR_DIR}/*.creator file"
|
||||
echo "In QTCreator select an 'open project...' option and find a ${QTCREATOR_DIR}/*.creator file"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
@@ -40,6 +40,10 @@ clangd: FORCE
|
||||
@.templates/install_clangd.sh
|
||||
|
||||
|
||||
forceclangd: FORCE
|
||||
@.templates/install_clangd.sh force
|
||||
|
||||
|
||||
clangdall: clangd
|
||||
@$(MAKE) -C ../pikotools clangd
|
||||
@$(MAKE) -C ../morm clangd
|
||||
@@ -47,10 +51,21 @@ clangdall: clangd
|
||||
@$(MAKE) -C ../tito clangd
|
||||
|
||||
|
||||
forceclangdall: forceclangd
|
||||
@$(MAKE) -C ../pikotools forceclangd
|
||||
@$(MAKE) -C ../morm forceclangd
|
||||
@$(MAKE) -C ../ezc forceclangd
|
||||
@$(MAKE) -C ../tito forceclangd
|
||||
|
||||
|
||||
qtcreator: clangd
|
||||
@.templates/install_qtcreator.sh
|
||||
|
||||
|
||||
forceqtcreator: forceclangd
|
||||
@.templates/install_qtcreator.sh force
|
||||
|
||||
|
||||
qtcreatorall: qtcreator
|
||||
@$(MAKE) -C ../pikotools qtcreator
|
||||
@$(MAKE) -C ../morm qtcreator
|
||||
@@ -58,5 +73,12 @@ qtcreatorall: qtcreator
|
||||
@$(MAKE) -C ../tito qtcreator
|
||||
|
||||
|
||||
forceqtcreatorall: forceqtcreator
|
||||
@$(MAKE) -C ../pikotools forceqtcreator
|
||||
@$(MAKE) -C ../morm forceqtcreator
|
||||
@$(MAKE) -C ../ezc forceqtcreator
|
||||
@$(MAKE) -C ../tito forceqtcreator
|
||||
|
||||
|
||||
FORCE:
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2008-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -180,10 +180,9 @@ void Config::AssignValues()
|
||||
image_quality = Int(L"image_quality", 92);
|
||||
convert_cmd = Text(L"convert_cmd", L"/usr/local/bin/convert");
|
||||
|
||||
templates_dir = Text(L"templates_dir");
|
||||
templates_dir_default = Text(L"templates_dir_default");
|
||||
txt_templates_dir = Text(L"txt_templates_dir");
|
||||
txt_templates_dir_default = Text(L"txt_templates_dir_default");
|
||||
ListText(L"html_templates_dirs", html_templates_dirs);
|
||||
ListText(L"txt_templates_dirs", txt_templates_dirs);
|
||||
|
||||
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
||||
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
||||
templates_index = Text(L"templates_index", L"index.html");
|
||||
@@ -267,8 +266,7 @@ void Config::AssignValues()
|
||||
html_filter_orphans_mode_str = Text(L"html_filter_orphans_mode_str", L"nbsp");
|
||||
html_filter_nofilter_tag = Text(L"html_filter_nofilter_tag", L"nofilter");
|
||||
|
||||
locale_dir = Text(L"locale_dir");
|
||||
locale_dir_default = Text(L"locale_dir_default");
|
||||
ListText(L"locale_dirs", locale_dirs);
|
||||
locale_max_id = Size(L"locale_max_id", 100);
|
||||
locale_default_id = Size(L"locale_default_id", 0);
|
||||
ListText(L"locale_files", locale_files);
|
||||
@@ -523,6 +521,8 @@ bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & lis
|
||||
return space.to_list(name, list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Config::HasValue(const wchar_t * name, const wchar_t * value)
|
||||
{
|
||||
return space.has_value(name, value);
|
||||
|
||||
+15
-12
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2008-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -186,11 +186,13 @@ public:
|
||||
// default: 3
|
||||
size_t fcgi_cannot_create_request_delay;
|
||||
|
||||
std::wstring templates_dir;
|
||||
std::wstring templates_dir_default; // html templates from winix
|
||||
// html templates directories
|
||||
// by default a file from the last directory is chosen
|
||||
std::vector<std::wstring> html_templates_dirs;
|
||||
|
||||
std::wstring txt_templates_dir;
|
||||
std::wstring txt_templates_dir_default; // txt (notifications) templates from winix
|
||||
// txt (notifications) templates directories
|
||||
// by default a file from the last directory is chosen
|
||||
std::vector<std::wstring> txt_templates_dirs;
|
||||
|
||||
// prefix and postfix for functions templates
|
||||
// default:
|
||||
@@ -590,14 +592,15 @@ public:
|
||||
// default: /usr/local/bin/convert
|
||||
std::wstring convert_cmd;
|
||||
|
||||
// directory with locale files
|
||||
std::wstring locale_dir;
|
||||
|
||||
// directory with default locale files (those from winix)
|
||||
std::wstring locale_dir_default;
|
||||
// directories with locale files
|
||||
// we start reading locale from the first directory
|
||||
// and files with the same name in each directory are concatenated
|
||||
std::vector<std::wstring> locale_dirs;
|
||||
|
||||
// locale files (e.g. "en", "pl")
|
||||
// default: only one item: en
|
||||
// default: "en"
|
||||
// a locale file should define winix_locale_id integer parameter
|
||||
// and it should be smaller or equal to locale_max_id
|
||||
std::vector<std::wstring> locale_files;
|
||||
|
||||
// a maximum value of a locale identifier
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2008-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -97,7 +97,7 @@ bool Notify::Init()
|
||||
if( !thread_manager->Add(¬ify_thread, L"notifications") )
|
||||
return false;
|
||||
|
||||
patterns.SetDirectories(config->txt_templates_dir, config->txt_templates_dir_default);
|
||||
patterns.SetDirectories(config->txt_templates_dirs);
|
||||
patterns.SetLocale(&TemplatesFunctions::locale);
|
||||
patterns.SetLocaleFilter(&TemplatesFunctions::locale_filter);
|
||||
|
||||
|
||||
+71
-81
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2010-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -49,13 +49,18 @@ Locale::Locale()
|
||||
}
|
||||
|
||||
|
||||
void Locale::SetDirectories(const std::vector<std::wstring> & dirs)
|
||||
{
|
||||
directories = dirs;
|
||||
}
|
||||
|
||||
|
||||
void Locale::SetLocaleFiles(const std::vector<std::wstring> & files)
|
||||
{
|
||||
locale_files = files;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Locale::SetLocaleMaxId(size_t max_id)
|
||||
{
|
||||
if( max_id > 1000 )
|
||||
@@ -72,8 +77,6 @@ void Locale::SetLocaleMaxId(size_t max_id)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Locale::HasLanguage(size_t lang_id)
|
||||
{
|
||||
if( lang_id < locale_indices.size() )
|
||||
@@ -83,34 +86,38 @@ return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Locale::ReadFile(const char * dir, const char * dir_def, const char * file)
|
||||
void Locale::ReadFile(const std::wstring & file)
|
||||
{
|
||||
bool read = false;
|
||||
temp_space.clear();
|
||||
|
||||
if( dir_def && ReadFile(dir_def, file) )
|
||||
read = true;
|
||||
|
||||
if( dir && ReadFile(dir, file) )
|
||||
read = true;
|
||||
for(const std::wstring & dir : directories)
|
||||
{
|
||||
if( ReadFile(dir, file) )
|
||||
read = true;
|
||||
}
|
||||
|
||||
if( read )
|
||||
{
|
||||
AddLocale(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Locale: can't open locale's file: " << file << logend;
|
||||
}
|
||||
|
||||
temp_space.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Locale::ReadFile(const char * dir, const char * file)
|
||||
bool Locale::ReadFile(const std::wstring & dir, const std::wstring & file)
|
||||
{
|
||||
bool read = false;
|
||||
bool read = false;
|
||||
|
||||
file_name = dir;
|
||||
pt::wide_to_utf8(dir, file_name);
|
||||
file_name += '/';
|
||||
file_name += file;
|
||||
pt::wide_to_utf8(file, file_name, false);
|
||||
|
||||
pt::SpaceParser::Status status = loc_parser.parse_space_file(file_name, temp_space, false);
|
||||
|
||||
@@ -125,23 +132,24 @@ bool read = false;
|
||||
log << log1 << "Locale: syntax error in: " << file_name << " in line: " << loc_parser.get_last_parsed_line() << logend;
|
||||
}
|
||||
|
||||
return read;
|
||||
file_name.clear();
|
||||
return read;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Locale::AddLocale(const char * file)
|
||||
void Locale::AddLocale(const std::wstring & file)
|
||||
{
|
||||
std::wstring * id_str = temp_space.get_wstr(L"winix_locale_id");
|
||||
|
||||
if( !id_str )
|
||||
{
|
||||
log << log1 << "Locale: winix_locale_id field should be defined in locale file: "
|
||||
<< file << " (skipping)" << logend;
|
||||
log << log1 << "Locale: winix_locale_id field should be defined in a locale file: "
|
||||
<< file << " (skipping this file)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
size_t id = (size_t)Tol(*id_str);
|
||||
size_t id = (size_t)pt::to_ul(*id_str);
|
||||
|
||||
if( id >= locale_indices.size() )
|
||||
{
|
||||
@@ -155,32 +163,35 @@ void Locale::AddLocale(const char * file)
|
||||
|
||||
|
||||
|
||||
void Locale::ReadSubstTable(const char * dir, const char * dir_def)
|
||||
void Locale::ReadSubstTable()
|
||||
{
|
||||
bool read = false;
|
||||
|
||||
bool read = false;
|
||||
temp_space.clear();
|
||||
subst_url.clear();
|
||||
subst_smalllet.clear();
|
||||
subst_capitallet.clear();
|
||||
subst_sort.clear();
|
||||
|
||||
if( dir_def && ReadSubstTable(dir_def) )
|
||||
read = true;
|
||||
|
||||
if( dir && ReadSubstTable(dir) )
|
||||
read = true;
|
||||
for(const std::wstring & dir : directories)
|
||||
{
|
||||
if( ReadSubstTable(dir) )
|
||||
read = true;
|
||||
}
|
||||
|
||||
if( !read )
|
||||
log << log1 << "Locale: can't open file for characters substitution" << logend;
|
||||
{
|
||||
log << log1 << "Locale: can't open a file for characters substitution" << logend;
|
||||
}
|
||||
|
||||
temp_space.clear();
|
||||
}
|
||||
|
||||
|
||||
bool Locale::ReadSubstTable(const char * dir)
|
||||
bool Locale::ReadSubstTable(const std::wstring & dir)
|
||||
{
|
||||
bool read = false;
|
||||
bool read = false;
|
||||
|
||||
file_name = dir;
|
||||
pt::wide_to_utf8(dir, file_name);
|
||||
file_name += '/';
|
||||
file_name += "substitute";
|
||||
|
||||
@@ -199,7 +210,8 @@ bool read = false;
|
||||
log << log3 << "Locale: read characters substitution tables from: " << file_name << logend;
|
||||
}
|
||||
|
||||
return read;
|
||||
file_name.clear();
|
||||
return read;
|
||||
}
|
||||
|
||||
|
||||
@@ -254,58 +266,36 @@ void Locale::CreateSubstSortVector(std::vector<SubstItem> & vect, std::vector<st
|
||||
}
|
||||
|
||||
|
||||
void Locale::Read(const char * dir, const char * dir_def)
|
||||
void Locale::ReadLocales()
|
||||
{
|
||||
for(size_t & index : locale_indices)
|
||||
index = size_t(-1);
|
||||
|
||||
for(const std::wstring & file : locale_files)
|
||||
{
|
||||
ReadFile(file);
|
||||
}
|
||||
|
||||
ReadSubstTable();
|
||||
}
|
||||
|
||||
|
||||
void Locale::Clear()
|
||||
{
|
||||
directories.clear();
|
||||
locale_files.clear();
|
||||
locale_indices.clear();
|
||||
locale_tab.clear();
|
||||
default_lang = 0;
|
||||
current_lang = 0;
|
||||
|
||||
for(size_t i=0 ; i<locale_indices.size() ; ++i)
|
||||
locale_indices[i] = size_t(-1);
|
||||
|
||||
for(size_t i=0 ; i<locale_files.size() ; ++i)
|
||||
{
|
||||
pt::wide_to_utf8(locale_files[i], locale_filea);
|
||||
ReadFile(dir, dir_def, locale_filea.c_str());
|
||||
}
|
||||
|
||||
ReadSubstTable(dir, dir_def);
|
||||
subst_url.clear();
|
||||
subst_smalllet.clear();
|
||||
subst_capitallet.clear();
|
||||
subst_sort.clear();
|
||||
}
|
||||
|
||||
|
||||
void Locale::Read(const std::string & dir, const std::string & dir_def)
|
||||
{
|
||||
if( dir_def.empty() )
|
||||
Read(dir.c_str());
|
||||
else
|
||||
Read(dir.c_str(), dir_def.c_str());
|
||||
}
|
||||
|
||||
|
||||
void Locale::Read(const wchar_t * dir, const wchar_t * dir_def)
|
||||
{
|
||||
pt::wide_to_utf8(dir, adir1);
|
||||
|
||||
if( !dir_def )
|
||||
{
|
||||
Read(adir1.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
pt::wide_to_utf8(dir_def, adir2);
|
||||
Read(adir1.c_str(), adir2.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Locale::Read(const std::wstring & dir, const std::wstring & dir_def)
|
||||
{
|
||||
if( dir_def.empty() )
|
||||
Read(dir.c_str());
|
||||
else
|
||||
Read(dir.c_str(), dir_def.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Locale::SetCurLang(size_t lang_id)
|
||||
{
|
||||
|
||||
+18
-15
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2010-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -53,8 +53,11 @@ public:
|
||||
|
||||
Locale();
|
||||
|
||||
// locale directories
|
||||
void SetDirectories(const std::vector<std::wstring> & dirs);
|
||||
|
||||
// locale files
|
||||
// those files will be reading from directories specified in Read() method
|
||||
// those files will be reading from directories specified above
|
||||
// default one item: en
|
||||
void SetLocaleFiles(const std::vector<std::wstring> & files);
|
||||
|
||||
@@ -73,11 +76,11 @@ public:
|
||||
size_t GetDefLang() const;
|
||||
|
||||
// reading locales
|
||||
// you should call SetLocaleFiles() beforehand
|
||||
void Read(const char * dir, const char * dir_def = 0);
|
||||
void Read(const std::string & dir, const std::string & dir_def);
|
||||
void Read(const wchar_t * dir, const wchar_t * dir_def = 0);
|
||||
void Read(const std::wstring & dir, const std::wstring & dir_def);
|
||||
// you should call SetDirectories(), SetLocaleFiles() and SetLocaleMaxId() beforehand
|
||||
void ReadLocales();
|
||||
|
||||
// clear directories, files and read translations
|
||||
void Clear();
|
||||
|
||||
// returns true if a language with lang_id exists
|
||||
bool HasLanguage(size_t lang_id);
|
||||
@@ -208,11 +211,11 @@ private:
|
||||
bool operator<(const SubstItem & arg) const { return from < arg.from; }
|
||||
};
|
||||
|
||||
void AddLocale(const char * file);
|
||||
void ReadFile(const char * dir, const char * dir_def, const char * file);
|
||||
bool ReadFile(const char * dir, const char * file);
|
||||
void ReadSubstTable(const char * dir, const char * dir_def);
|
||||
bool ReadSubstTable(const char * dir);
|
||||
void AddLocale(const std::wstring & file);
|
||||
void ReadFile(const std::wstring & file);
|
||||
bool ReadFile(const std::wstring & dir, const std::wstring & file);
|
||||
void ReadSubstTable();
|
||||
bool ReadSubstTable(const std::wstring & dir);
|
||||
void CreateSubstVector(std::vector<SubstItem> & vect, const std::wstring & tab1, const std::wstring & tab2);
|
||||
void CreateSubstSortVector(std::vector<SubstItem> & vect, std::vector<std::wstring> & tab);
|
||||
size_t SubstFindIndex(const std::vector<SubstItem> & vect, wchar_t val);
|
||||
@@ -221,6 +224,8 @@ private:
|
||||
bool GetListInLanguage(const std::wstring & key, size_t lang_id, std::vector<std::wstring> & list) const;
|
||||
bool IsListInLanguage(const std::wstring & key, size_t lang_id) const;
|
||||
|
||||
// directories
|
||||
std::vector<std::wstring> directories;
|
||||
|
||||
// locale files
|
||||
std::vector<std::wstring> locale_files;
|
||||
@@ -252,11 +257,9 @@ private:
|
||||
|
||||
pt::Space temp_space;
|
||||
pt::SpaceParser loc_parser;
|
||||
std::string locale_filea;
|
||||
std::string file_name;
|
||||
std::wstring key_str;
|
||||
const std::wstring empty; // used when returning a non existing key from loc_tab (or in LangToFileName)
|
||||
std::string adir1, adir2;
|
||||
std::wstring pattern_value;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2015, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2011-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -59,13 +59,16 @@ void Patterns::SetDeleteWhiteItems(bool del_white)
|
||||
}
|
||||
|
||||
|
||||
void Patterns::SetDirectories(const std::wstring & tmpl_dir, const std::wstring & tmpl_dir_def)
|
||||
void Patterns::SetDirectories(const std::vector<std::wstring> & tmpl_dirs)
|
||||
{
|
||||
templates_dir = tmpl_dir;
|
||||
templates_dir_def = tmpl_dir_def;
|
||||
templates_dirs = tmpl_dirs;
|
||||
}
|
||||
|
||||
|
||||
void Patterns::ClearDirectories()
|
||||
{
|
||||
templates_dirs.clear();
|
||||
}
|
||||
|
||||
|
||||
void Patterns::SetLocale(Locale * plocale)
|
||||
@@ -138,7 +141,7 @@ void Patterns::ReadPatterns(Template & templ)
|
||||
* pattern_parser.SetCommentary() is set beforehand
|
||||
*/
|
||||
pattern_parser.DeleteWhiteTextItems(del_white_items);
|
||||
pattern_parser.Directory(templates_dir, templates_dir_def);
|
||||
pattern_parser.SetDirectories(templates_dirs);
|
||||
pattern_parser.SetLogger(&log);
|
||||
|
||||
if( ezc_blocks )
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2011-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
Patterns();
|
||||
|
||||
void SetDeleteWhiteItems(bool del_white);
|
||||
void SetDirectories(const std::wstring & tmpl_dir, const std::wstring & tmpl_dir_def);
|
||||
void SetDirectories(const std::vector<std::wstring> & tmpl_dirs);
|
||||
void ClearDirectories();
|
||||
|
||||
/*
|
||||
setting locale and locale_filter
|
||||
@@ -151,7 +152,7 @@ public:
|
||||
private:
|
||||
|
||||
bool del_white_items;
|
||||
std::wstring templates_dir, templates_dir_def;
|
||||
std::vector<std::wstring> templates_dirs;
|
||||
Locale * locale;
|
||||
LocaleFilter * locale_filter;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2008-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -678,10 +678,11 @@ void Templates::CreateFunctions()
|
||||
|
||||
void Templates::ReadLocale()
|
||||
{
|
||||
TemplatesFunctions::locale.SetDirectories(config->locale_dirs);
|
||||
TemplatesFunctions::locale.SetLocaleFiles(config->locale_files);
|
||||
TemplatesFunctions::locale.SetLocaleMaxId(config->locale_max_id);
|
||||
TemplatesFunctions::locale.SetDefLang(config->locale_default_id);
|
||||
TemplatesFunctions::locale.Read(config->locale_dir, config->locale_dir_default);
|
||||
TemplatesFunctions::locale.ReadLocales();
|
||||
|
||||
log << log3 << "Templates: there are " << TemplatesFunctions::locale.Size() << " locales" << logend;
|
||||
}
|
||||
@@ -868,7 +869,7 @@ void Templates::Init()
|
||||
{
|
||||
using namespace TemplatesFunctions;
|
||||
|
||||
patterns.SetDirectories(config->templates_dir, config->templates_dir_default);
|
||||
patterns.SetDirectories(config->html_templates_dirs);
|
||||
pattern_cacher.SetWhenDelete(config->pattern_cacher_when_delete, config->pattern_cacher_how_many_delete);
|
||||
CreateFunctions(); // create functions first (functions will be cached by patterns)
|
||||
ReadTemplates();
|
||||
|
||||
Reference in New Issue
Block a user