Add private shared class ArgumentVector

The parser is based on the FS shell's ArgVector.
This commit is contained in:
Ingo Weinhold
2012-07-20 23:32:58 +02:00
parent fc4d98a2c0
commit af350aa218
3 changed files with 257 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
/*
* Copyright 2007-2012, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _ARGUMENT_VECTOR_H
#define _ARGUMENT_VECTOR_H
#include <SupportDefs.h>
namespace BPrivate {
class ArgumentVector {
public:
enum ParseError {
NO_ERROR,
NO_MEMORY,
UNTERMINATED_QUOTED_STRING,
TRAILING_BACKSPACE
};
public:
ArgumentVector();
~ArgumentVector();
int32 ArgumentCount() const { return fCount; }
const char* const* Arguments() const { return fArguments; }
char** DetachArguments();
// Caller must free() -- it's all one big allocation at the
// returned pointer.
ParseError Parse(const char* commandLine,
const char** _errorLocation = NULL);
private:
struct Parser;
private:
char** fArguments;
int32 fCount;
};
} // namespace BPrivate
using BPrivate::ArgumentVector;
#endif // _ARGUMENT_VECTOR_H