로딩중...
검색중...
일치하는것 없음
by::flag 클래스 참조abstract

Base class for command-line flag handling 더 자세히 ...

#include <flag.hpp>

by::flag에 대한 상속 다이어그램 :
by::instance by::typeProvidable by::clonable by::bufferSrcFlag by::dirFlag by::fileFlag by::helpFlag by::logStructureFlag by::verFlag by::verboseFlag

Public 타입

enum  res { MATCH , EXIT_PROGRAM , NOT_MATCH }
 

Public 멤버 함수

virtual const nchargetName () const =0
 
virtual const nchargetDescription () const =0
 
virtual res take (interpreter &ip, starter &s, cli &c, flagArgs &a, errReport &rpt) const
 
nbool canTake (const std::string &pattern) const
 
- by::instance(으)로부터 상속된 Public 멤버 함수
 instance (id newId)
 
 instance (const me &rhs)
 
me & operator= (const me &rhs)=default
 
void * operator new (size_t sz) noexcept
 
void operator delete (void *pt, size_t sz) noexcept
 
virtual id getId () const
 
virtual nbool isHeap () const
 Checks if this instance is allocated on the heap.
 
const lifegetBindTag () const
 Returns a pointer to the associated life object for reference counting.
 
- by::typeProvidable(으)로부터 상속된 Public 멤버 함수
nbool operator== (const me &rhs) const
 
nbool operator!= (const me &rhs) const
 
virtual const typegetType () const =0
 
nbool isSub (const type &it) const
 
nbool isSub (const type *it) const BY_SIDE_FUNC(isSub)
 
nbool isSub (const me &it) const
 
nbool isSub (const me *it) const BY_SIDE_FUNC(isSub)
 
nbool isSuper (const type &it) const
 
nbool isSuper (const type *it) const BY_SIDE_FUNC(isSuper)
 
nbool isSuper (const me &it) const
 
nbool isSuper (const me *it) const BY_SIDE_FUNC(isSuper)
 
template<typename T >
nint isSub () const
 
template<typename T >
nint isSuper () const
 
template<typename T >
T * cast ()
 
template<typename T >
const T * cast () const BY_CONST_FUNC(cast< T >()) virtual void *cast(const type &to)
 Safe cast to target type using type hierarchy information
 
const void * cast (const type &to) const BY_CONST_FUNC(cast(to)) void *cast(const type *it) BY_SIDE_FUNC(cast)
 
- by::clonable(으)로부터 상속된 Public 멤버 함수
virtual me * clone () const =0
 
virtual me * cloneDeep () const
 
virtual void onCloneDeep (const me &from)
 

Protected 멤버 함수

virtual ncnt getArgCount () const
 
void _delArgs (flagArgs &a, ncnt deleteOptionCnt) const
 Deletes arguments from the flagArgs list.
 
virtual const strings & _getRegExpr () const =0
 
virtual res _onTake (const flagArgs &tray, cli &c, interpreter &ip, starter &s, errReport &rpt) const =0
 
- by::instance(으)로부터 상속된 Protected 멤버 함수
nbool _setId (id new1)
 

추가로 상속된 멤버들

- by::instance(으)로부터 상속된 정적 Public 멤버 함수
static vaultgetVault ()
 
- by::instance(으)로부터 상속된 정적 Protected 멤버 함수
static instancer_getMgr ()
 

상세한 설명

Base class for command-line flag handling

Handles flags commonly seen in shell-based programs. Note this class doesn't represent a flag like --version, but rather handles whether such flags exist and what actions to take.

Flag descriptions

Each flag defines not only its name but also a description of its functionality. These are used by helpFlag.

Regex pattern matching

Each flag class has a defined pattern to search for. For example, verFlag searches for the --version string in program arguments. If found, it retrieves version info from buildFeature and outputs it. This behavior works by calling flag::take(), which uses the regex defined in each derived class's _getRegExpr() to find the desired pattern. Since regex is used, flag order is ignored.

Multiple patterns can be defined in regex:

const strings& me::_getRegExpr() const {
static strings inner{"^\\-S$", "^\\--show-structure$"};
return inner;
}
Rich logging support with polymorphic type conversion
Definition richLog.hpp:34

Matches either ^\-S$ or ^\--show-structure$.

Consuming multiple flag arguments

Consider verFlag: when --version exists in arguments, it outputs version. After operating, it removes --version from flagArgs to prevent verFlag from running again.

Now consider bufferSrcFlag, used like: --script "main() void: print(\"wow!\")"

Breaking this down: --script indicates flag start, followed by space and "<your code>" which is the frontend code body argument to execute. Some flags consume not just the matched pattern but additional arguments. Each derived flag class can override getArgCount() to specify how many additional arguments to extract.

Terminating flags

bufferSrcFlag needs preliminary work before program start. Conversely, verFlag immediately outputs version and terminates without interpretation once matched (as most programs do). To terminate immediately after matching, override _onTake() to return EXIT_PROGRAM. For continued operation like bufferSrcFlag, return MATCH.

멤버 함수 문서화

◆ _delArgs()

void by::flag::_delArgs ( flagArgs & a,
ncnt deleteOptionCnt ) const
protected

Deletes arguments from the flagArgs list.

This method is used internally to remove arguments that have been consumed by this flag, preventing them from being processed again by other flags.

매개변수
aThe flagArgs instance from which arguments are to be deleted.
deleteOptionCnta count indicating how much arguments to delete.

◆ canTake()

nbool by::flag::canTake ( const std::string & pattern) const
매개변수
patternit's used to determine whether a pattern for a flag or not. it usually starts with one or two hyphens.

◆ getArgCount()

virtual ncnt by::flag::getArgCount ( ) const
protectedvirtual

when this flag matched to one of args, the value of returning this func will be count of continuous argument of this flag.

by::bufferSrcFlag에서 재구현되었습니다.

◆ take()

virtual res by::flag::take ( interpreter & ip,
starter & s,
cli & c,
flagArgs & a,
errReport & rpt ) const
virtual
반환값
false if flag wants to exit program.

이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: