blob: 7b109d612e33a32e8fe01c9114eed029c4f9d1ca (
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
|
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include <IceUtil/ArgVector.h>
#include <IceUtil/DisableWarnings.h>
#include <cstring>
IceUtilInternal::ArgVector::ArgVector(int argc, char* const argv[])
{
assert(argc >= 0);
_args.resize(argc);
for(int i = 0; i < argc; ++i)
{
_args[i] = argv[i];
}
setupArgcArgv();
}
IceUtilInternal::ArgVector::ArgVector(const ::std::vector< ::std::string>& vec)
{
_args = vec;
setupArgcArgv();
}
IceUtilInternal::ArgVector::ArgVector(const ArgVector& rhs)
{
_args = rhs._args;
setupArgcArgv();
}
IceUtilInternal::ArgVector&
IceUtilInternal::ArgVector::operator=(const ArgVector& rhs)
{
delete[] argv;
argv = 0;
_args = rhs._args;
setupArgcArgv();
return *this;
}
IceUtilInternal::ArgVector::~ArgVector()
{
delete[] argv;
}
void
IceUtilInternal::ArgVector::setupArgcArgv()
{
argc = static_cast<int>(_args.size());
if((argv = new char*[argc + 1]) == 0)
{
throw ::std::bad_alloc();
}
for(int i = 0; i < argc; i++)
{
argv[i] = const_cast<char*>(_args[i].c_str());
}
argv[argc] = 0;
}
|