10# if !defined (HPP_ALIB_CONFIG_PLUGINS)
14# if !defined (HPP_ALIB_CAMP_ENVIRONMENT)
17# if !defined (HPP_ALIB_CONFIG_CONFIG)
21# if !defined (HPP_ALIB_LANG_CAMP_INLINES)
27namespace alib {
namespace config {
41 bool lastWasSlash=
false;
62 dest.
_<
false>(escChr);
83 || parser.
IndexOf( delim ) >= 0;
93 case '"' : dest.
_<
false>(needsQuotes ?
"\\\"" :
"\"");
95 case '\\' : dest.
_<
false>(
"\\\\");
break;
96 case '\r' : dest.
_<
false>(
"\\r" );
break;
97 case '\n' : dest.
_<
false>(
"\\n" );
break;
98 case '\t' : dest.
_<
false>(
"\\t" );
break;
99 case '\a' : dest.
_<
false>(
"\\a" );
break;
100 case '\b' : dest.
_<
false>(
"\\b" );
break;
101 case '\v' : dest.
_<
false>(
"\\v" );
break;
102 case '\f' : dest.
_<
false>(
"\\f" );
break;
103 case '\033' : dest.
_<
false>(
"\\e" );
break;
104 default : dest.
_<
false>(c);
break;
118 if( variable.
Delim() ==
'\0' )
121 variable.
Add( tempBuf );
127 bool lastWasSlash=
false;
129 while( idx < src.
Length() )
151 if( !inQuote && c == variable.
Delim() )
155 variable.
Add(tempBuf);
166 variable.
Add( tempBuf );
181 bool allowWithoutCategory=
false;
183 if( (allowWithoutCategory= variable.
Category().
Equals<
false>( defaultCategory )) == true )
190 std::vector<AString>::iterator argsIt;
213 if(!std::is_same<character, char>::value)
215 stringConverter.
Reset(
reinterpret_cast<const char**
>(
argVector)[i] );
216 cliArg= stringConverter;
223 if(!std::is_same<character, wchar_t>::value)
225 stringConverter.
Reset(
reinterpret_cast<const wchar_t**
>(
argVector)[i] );
226 cliArg= stringConverter;
287 CLIArgsIteratorImpl(
CLIArgs& cliArgs,
const String& pSectionName )
289 , sectionName(pSectionName)
295 virtual ~CLIArgsIteratorImpl()
override
298 virtual bool Next( Variable& variable )
override
300 return detail::nextCLIArg( parent, nextArgNo, sectionName, variable );
312 size_t qtyArgs= cliArgs.argCount;
313 std::vector<AString>::iterator argsIt;
314 if( !cliArgs.AlternativeArgs.empty() )
316 qtyArgs= cliArgs.AlternativeArgs.size();
317 argsIt= cliArgs.AlternativeArgs.begin();
320 if( nextArgNo >= qtyArgs )
324 bool allowWithoutCategory=
false;
325 for (
auto& defaultCategory : cliArgs.DefaultCategories )
326 if( (allowWithoutCategory= sectionName.
Equals( defaultCategory )) == true )
330 stringConverter.DbgDisableBufferReplacementWarning();
333 if( nextArgNo == 0 && cliArgs.AlternativeArgs.empty() )
335 while( nextArgNo < qtyArgs )
339 if( !cliArgs.AlternativeArgs.empty() )
349 if(!std::is_same<character, char>::value)
351 stringConverter.Reset(
reinterpret_cast<const char**
>(cliArgs.argVector)[nextArgNo] );
352 cliArg= stringConverter;
355 cliArg=
reinterpret_cast<const character**
>(cliArgs.argVector)[nextArgNo];
359 if(!std::is_same<character, wchar_t>::value)
361 stringConverter.Reset(
reinterpret_cast<const wchar_t**
>(cliArgs.argVector)[nextArgNo] );
362 cliArg= stringConverter;
365 cliArg=
reinterpret_cast<const character**
>(cliArgs.argVector)[nextArgNo];
373 if ( !cliArg.ConsumeChar(
'-') )
375 cliArg.ConsumeChar(
'-');
378 if( !allowWithoutCategory && !sectionName.IsEmpty()
380 || !cliArg.ConsumeChar(
'_' ) ) )
384 integer equalSignPos= cliArg.IndexOf(
'=' );
385 if( equalSignPos < 0 )
390 cliArg .
Split ( equalSignPos, value, 1);
391 variable.Declare( sectionName, cliArg );
392 cliArgs.StringConverter->LoadFromString( variable, value.Trim() );
403 return new CLIArgsIteratorImpl( *
this, sectionName );
425 nameZeroTerminated << variable.
Fullname();
size_t argCount
The number of command line arguments.
virtual ALIB_API bool Load(Variable &variable, bool searchOnly=false) override
const void ** argVector
The list of command line arguments.
virtual ALIB_API Iterator * GetIterator(const String §ionName) override
virtual ALIB_API String Name() const override
std::vector< AString > AlternativeArgs
int AllowedMinimumShortCut
std::vector< AString > DefaultCategories
XTernalizer * StringConverter
virtual ALIB_API bool Load(Variable &variable, bool searchOnly=false) override
virtual ALIB_API String Name() const override
ALIB_API const String & Fullname()
ALIB_API void Add(const String &value)
const String & Name() const
const String & Category() const
Variable & ClearValues(int startIdx=0)
virtual ALIB_API void ExternalizeValue(const String &src, AString &dest, character delim)
virtual ALIB_API void InternalizeValue(const String &src, AString &dest)
virtual ALIB_API void LoadFromString(Variable &variable, const String &src)
const String & GetResource(const NString &name)
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
void DbgDisableBufferReplacementWarning()
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsEmpty() const
TChar CharAt(integer idx) const
constexpr bool IsNotEmpty() const
constexpr integer Length() const
TChar CharAtStart() const
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
bool Equals(const TString< TChar > &rhs) const
TSubstring & Trim(const TCString< TChar > &whiteSpaces=TT_StringConstants< TChar >::DefaultWhitespaces())
bool ConsumeString(const TString< TChar > &consumable)
TSubstring & Split(integer position, TSubstring &target, integer separatorWidth=0, bool trim=false)
integer ConsumePartOf(const TString< TChar > &consumable, int minChars=1)
integer ConsumeChars(integer regionLength, TSubstring *target=nullptr)
TSubstring & TrimStart(const TCString< TChar > &whiteSpaces=TT_StringConstants< TChar >::DefaultWhitespaces())
bool ConsumeCharFromEnd(TChar consumable)
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
bool nextCLIArg(CLIArgs &cliArgs, size_t &nextArgNo, const String §ionName, Variable &variable)
@ Equals
Verbal alias "Equals" to operator '=='.
@ Trim
Trim whitespaces away.
@ Keep
Chooses not no clear existing data.
@ Clear
Chooses to clear existing data.
config::Variable Variable
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
LocalString< 256 > String256
Type alias name for TLocalString<character,256> .
characters::character character
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
static ALIB_API bool Get(const CString &varName, AString &target, lang::CurrentData targetData=lang::CurrentData::Clear)