File: types.h

package info (click to toggle)
cppdap 1.58.0a-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 904 kB
  • sloc: cpp: 6,590; ansic: 1,184; sh: 123; makefile: 16
file content (104 lines) | stat: -rw-r--r-- 2,408 bytes parent folder | download | duplicates (5)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This file holds the basic serializable types used by the debug adapter
// protocol.

#ifndef dap_types_h
#define dap_types_h

#include "any.h"
#include "optional.h"
#include "variant.h"

#include <unordered_map>
#include <vector>

#include <stdint.h>

namespace dap {

// string is a sequence of characters.
// string defaults to an empty string.
using string = std::string;

// boolean holds a true or false value.
// boolean defaults to false.
class boolean {
 public:
  inline boolean() : val(false) {}
  inline boolean(bool i) : val(i) {}
  inline operator bool() const { return val; }
  inline boolean& operator=(bool i) {
    val = i;
    return *this;
  }

 private:
  bool val;
};

// integer holds a whole signed number.
// integer defaults to 0.
class integer {
 public:
  inline integer() : val(0) {}
  inline integer(int64_t i) : val(i) {}
  inline operator int64_t() const { return val; }
  inline integer& operator=(int64_t i) {
    val = i;
    return *this;
  }
  inline integer operator++(int) {
    auto copy = *this;
    val++;
    return copy;
  }

 private:
  int64_t val;
};

// number holds a 64-bit floating point number.
// number defaults to 0.
class number {
 public:
  inline number() : val(0.0) {}
  inline number(double i) : val(i) {}
  inline operator double() const { return val; }
  inline number& operator=(double i) {
    val = i;
    return *this;
  }

 private:
  double val;
};

// array is a list of items of type T.
// array defaults to an empty list.
template <typename T>
using array = std::vector<T>;

// object is a map of string to any.
// object defaults to an empty map.
using object = std::unordered_map<string, any>;

// null represents no value.
// null is used by any to check for no-value.
using null = std::nullptr_t;

}  // namespace dap

#endif  // dap_types_h