61 return reinterpret_cast<T*
>(
reinterpret_cast<const char*
>(ptr) +
m_CmdDefSize);
77 const char* tok_start = s;
79 if (*s ==
'"' || *s ==
'\'') {
93 for (; s < str_end; ++s) {
95 if (*s == quote_char) {
98 else if (*s ==
'\\' && (s + 1 < str_end)) {
102 else if (*s ==
'=' ||
isspace(*s))
112 else if (ttype ==
eNSTT_Str && *s != quote_char) {
114 "String is not ended correctly: \""
115 <<
string(tok_start, s - tok_start));
117 else if (ttype ==
eNSTT_Int && s > *
str && *(s - 1) ==
'-') {
121 token->
assign(tok_start, s - tok_start);
124 if (token->
size() > 4 && tok_start[0] ==
'I' && tok_start[1] ==
'C'
125 && tok_start[2] ==
'(' && *(s - 1) ==
')')
140 while ((s < str_end) &&
isspace(*s)) {
151 const void** match_cmd,
166 "Command name is absent: '" <<
command <<
"'");
172 if (strlen(*cmd_name) == token.
size()
184 "Unknown command name '" << token <<
"' in command '"
187 *match_cmd = cmd_name;
189 if (!cache_name.
empty()) {
192 (*params)[argsDescr->
key] = cache_name;
210 const char* from = arg_descr->
dflt;
212 (*params)[arg_descr->
key] = from;
222 const char* str_end =
str + args.
size();
233 "Second equal sign met in the parameter value: '"
234 <<
string(
val.data(),
val.size() + 1) <<
"'");
246 bool matched =
false;
251 "Only key=value pairs allowed at the end of command");
256 matched = strlen(arg_descr->
key) ==
val.size()
280 "Argument " << arg_descr->
key <<
" is obsolete."
281 " It cannot be used in command now.");
291 (*params)[arg_descr->
key]
317 "Not all required parameters given. "
318 "Next parameter needed is '" << arg_descr->
key <<
"'");
334 "IC Prefix can be only the first in the arguments list "
335 "of a command map.");
337 if (!
key.empty() && !(strlen(arg_descr->
key) ==
key.size()
348 ||
static_cast<int>(arg_descr->
atype) ==
static_cast<int>(val_type))
@ eNoCommand
Empty line in protocol or invalid command.
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
const char *const * m_CmdMapName
void ParseCommand(CTempString command, const void **match_cmd, TNSProtoParams *params)
const SNSProtoArgument * m_CmdMapArgs
T * x_GetNextInCmdMap(T *ptr)
bool x_IsArgumentMatch(const CTempString key, ENSProtoTokenType val_type, const SNSProtoArgument *arg_descr)
ENSProtoTokenType x_GetToken(const char **str, const char *str_end, CTempString *token)
void ParseArguments(CTempString str, const SNSProtoArgument *arg_descr, TNSProtoParams *params)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
static const char * str(char *buf, int n)
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
#define FORMAT(message)
Format message using iostreams library.
void AddBacklog(const CDiagCompileInfo &info, const string &message, EDiagSev severity=eDiag_Error)
Add a message to backlog (to re-throw the same exception then).
static bool IsValidKey(const char *key_str, size_t key_len, CCompoundIDPool::TInstance id_pool=NULL)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CTempString & assign(const char *src_str, size_type len)
Assign new values to the content of the a string.
const char * data(void) const
Return a pointer to the array represented.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
size_type size(void) const
Return the length of the represented array.
const struct ncbi::grid::netcache::search::fields::KEY key
int strncmp(const char *str1, const char *str2, size_t count)
static void s_SetDefaultValue(TNSProtoParams *params, const SNSProtoArgument *arg_descr)
@ fNSPA_Match
This argument is exact match with "key" field and uses "dflt" field as value as opposed to default us...
@ fNSPA_Or
This argument is ORed to next a|b as opposed to default sequence a b.
@ fNSPA_Ellipsis
Just parse the rest as key=value, do not check anything, put these pairs in map.
@ fNSPA_Clear
Do not match this arg, just set to default.
@ fNSPA_Optional
The argument may be omitted.
@ fNSPA_Obsolete
Argument is now obsolete and using it causes parser error.
@ fNSPA_Chain
If the argument is absent, whole chain is ignored.
@ fNSPA_ICPrefix
Special value for IC prefix that precedes command itself.
@ eNSPA_None
end of arg list, intentionally set to 0