blob: 1f7e3c1dd2d6f486b3c8d55dda95de8bfb420d88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/********************* */
/*! \file preempt_get_option.h
** \verbatim
** Original author: Tim King
** Major contributors: none
** Minor contributors (to current version): none
** This file is part of the CVC4 project.
** Copyright (c) 2009-2014 New York University and The University of Iowa
** See the file COPYING in the top-level source directory for licensing
** information.\endverbatim
**
** \brief Utility function for extending commandline options.
**
** Utility function for extending commandline options.
**/
#include "cvc4_private.h"
#ifndef __CVC4__OPTIONS__PREMPT_GET_OPTION_H
#define __CVC4__OPTIONS__PREMPT_GET_OPTION_H
#include <cstddef>
#include <vector>
namespace CVC4 {
namespace options {
class ArgumentExtender {
public:
/**
* Preconditions:
* additional >= 1
* length >= 1
*/
ArgumentExtender(unsigned additional, size_t length);
~ArgumentExtender();
/**
* This purpose of this function is to massage argc and argv upon the event
* of parsing during Options::parseOptions of an option with the :link or
* :link-alternative attributes. The purpose of the function is to extend argv
* with another commandline argument.
*
* Preconditions:
* opt is '\0' terminated, non-null and non-empty c-string.
* strlen(opt) <= getLength()
*
* Let P be the first position in argv that is >= 1 and is either NULL or
* empty:
* argv[P] == NULL || argv[P] == '\0'
*
* This has a very specific set of side effects:
* - argc is incremented by one.
* - If argv[P] == NULL, this reallocates argv to have (P+additional)
* elements.
* - The 0 through P-1 elements of argv are the same.
* - The P element of argv is a copy of the first len-1 characters of opt.
* This is a newly allocated '\0' terminated c string of length len.
* - The P+1 through (P+additional-2) elements of argv are newly allocated
* empty '\0' terminated c strings of size len.
* - The last element at (P+additional-1) of argv is NULL.
* - All allocations are pushed back onto allocated.
*/
void extend(int& argc, char**& argv, const char* opt,
std::vector<char*>& allocated);
unsigned getIncrease() const;
size_t getLength() const;
private:
unsigned d_additional;
size_t d_length;
};
}/* CVC4::options namespace */
}/* CVC4 namespace */
#endif /* __CVC4__OPTIONS__PREMPT_GET_OPTION_H */
|