summaryrefslogtreecommitdiff
path: root/ace/ARGV.i
blob: f9fc1e73f12862b5ce870ad99d0286c7b2b6225c (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
/* -*- C++ -*- */
// $Id$

// Return the number of args
ACE_INLINE size_t
ACE_ARGV::argc (void) const
{
  ACE_TRACE ("ACE_ARGV::argc");
  return this->argc_;
}

// Return the state of this ACE_ARGV
ACE_INLINE int
ACE_ARGV::state(void) const
{
  ACE_TRACE ("ACE_ARGV::state");
  return this->state_;
}

// Return the arguments in a space-separated string
ACE_INLINE const ASYS_TCHAR *
ACE_ARGV::buf (void)
{
  ACE_TRACE ("ACE_ARGV::buf");

  if (this->buf_ == 0 && this->state_ == ITERATIVE) 
    this->create_buf_from_queue ();

  return (const ASYS_TCHAR *)this->buf_;
}

// Return the arguments in an entry-per-argument array

ACE_INLINE ASYS_TCHAR **
ACE_ARGV::argv (void)
{
  ACE_TRACE ("ACE_ARGV::argv");

  // Try to create the argv_ if it isn't there
  if (this->argv_ == 0) 
    {
      if (this->state_ == ITERATIVE && this->buf_ == 0)
        this->create_buf_from_queue ();

      // Convert buf_ to argv_
      if (this->string_to_argv () == -1)
        return 0;
    }

  return this->argv_;
}

// Subscript operator.  

ACE_INLINE const ASYS_TCHAR *
ACE_ARGV::operator[] (size_t i)
{
  ACE_TRACE ("ACE_ARGV::operator[]");

  // Don't go out of bounds.
  if (i >= this->argc_)
    return 0;

  return (const ASYS_TCHAR *) this->argv ()[i];
}