void qCtx::ParseArgs(qStr *in, qArgAry *out) { bool quot = false; bool more = true; qStrBuf cur; // bool trim = true; char c; do { while ( isspace((c = in->GetC())) ); if (c == T_SQ) { quot = true; c = in->GetC(); more = ParseArgQuoted(in, cur, c); } else { quot = false; more = ParseArg(in, cur, c); } out->Add(cur); cur.Grow(0); out->SetQuot(out->Count()-1,quot); } while (more && c != EOF); }
void qCtx::ParseArgsQmap(qStr *in, qArgAry *out, const char *qmap) { bool quot = false; bool more = true; // bool trim = true; // char quoted = '\x0'; // int qcnt = 0; char c; // int acnt = 0; if (!qmap) { ParseArgs(in, out); return; } char qmode = *qmap == 'A' ? '1' : *qmap == '1' ? '1' : '0'; if (*qmap != 'A' ) ++qmap; do { qStrBuf cur; while ( isspace((c = in->GetC())) ); if (c == T_SQ) { quot = true; c = in->GetC(); } else { quot = false; } if (qmode == '1' || quot) { more = ParseArgQuoted(in, cur, c); } else { more = ParseArg(in, cur, c); } out->Add(cur); out->SetQuot(out->Count()-1,quot); if (*qmap) { if (*qmap == '1') { qmode = '1'; ++qmap; } else if (*qmap == '0') { qmode = '0'; ++qmap; } } else { qmode = '0'; } } while (more && c != EOF); }
void qCtxComp::ParseCompArgs(qStr *in, qArgAry *out, char *qmap) { int quot = false; bool more = true; // bool trim = true; qStrBuf cur; // char quoted = '\x0'; // int qcnt = 0; char c; // int acnt = 0; char qmode; if (qmap) { qmode = *qmap == 'A' ? '1' : *qmap == '1' ? '1' : '0'; if (*qmap != 'A' ) ++qmap; else qmap = NULL; } else { qmode = '0'; } do { while ( isspace((c = in->GetC())) ); if (c == T_SQ) { quot = ARG_QSTR; c = in->GetC(); } else { quot = ARG_STR; } if (qmode == '1' || quot) { more = ParseArgQuoted(in, cur, c); } else { // more = ParseArgQuoted(in, cur, c); more = ParseCompArg(in, cur, c); quot = ARG_CMP; } out->Add(cur); cur.Grow(0); out->SetQuot(out->Count()-1,quot); if (qmap) { if (*qmap) { if (*qmap == '1') { qmode = '1'; ++qmap; } else if (*qmap == '0') { qmode = '0'; ++qmap; } } else { qmode = '0'; } } } while (more && c != EOF); }