aboutsummaryrefslogtreecommitdiff
path: root/build/variable.ixx
blob: 2cbe519e6b584047022a5bc12f8f1f60a7fb5e97 (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
// file      : build/variable.ixx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

namespace build
{
  inline const value_proxy& value_proxy::
  operator= (value_ptr v) const
  {
    *p = std::move (v);
    return *this;
  }

  inline const value_proxy& value_proxy::
  operator= (const value_proxy& v) const
  {
    if (this != &v)
    {
      if (v)
        *p = v.as<const value&> ().clone ();
      else
        p->reset ();
    }

    return *this;
  }

  inline const value_proxy& value_proxy::
  operator= (std::string v) const
  {
    // In most cases this is used to initialize a new variable, so
    // don't bother trying to optimize for the case where p is not
    // NULL.
    //
    p->reset (new list_value (std::move (v)));
    return *this;
  }

  inline const value_proxy& value_proxy::
  operator+= (std::string v) const
  {
    if (*p == nullptr)
      *this = v;
    else
      as<list_value&> ().emplace_back (std::move (v));

    return *this;
  }

  inline const value_proxy& value_proxy::
  operator= (dir_path v) const
  {
    p->reset (new list_value (std::move (v)));
    return *this;
  }

  inline const value_proxy& value_proxy::
  operator= (nullptr_t) const
  {
    p->reset ();
    return *this;
  }
}