Chain.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef H_CHAIN_INCLUDED
34 #define H_CHAIN_INCLUDED
35 
36 #include <Dynacoe/Util/Vector.h>
37 #include <string>
38 namespace Dynacoe {
39 
40 
41 
52 class Chain {
53 
54  public:
55 
56 
57 
58  Chain();
59 
64  Chain(const char *);
65  Chain(char);
66  Chain(int);
67  Chain(uint32_t);
68  Chain(uint64_t);
69  Chain(double);
70  Chain(const Vector &);
71  Chain(const Chain &);
72  Chain(const std::string & other);
73  Chain(const std::vector<Chain> &);
75 
76  ~Chain();
77 
78 
84  int AsInt();
85  uint32_t AsUInt32();
86  uint64_t AsUInt64();
87  float AsFloat();
88  double AsDouble();
90 
91 
94  Chain & operator<<(const Chain &);
95 
96 
97 
100  const std::string & ToString() const {
101  return data;
102  }
103 
104 
107  Chain & operator=(const Chain &);
108 
109 
110 
113  operator std::string() const {
114  return data;
115  }
116 
117 
121  std::string TranslateToAlBhed() const;
122  std::string TranslateFromAlBhed() const;
124 
125 
130  void NextLink();
131  Chain & operator++(int);
133 
136  std::string GetLink();
137 
140  uint32_t GetLinkPos();
141 
142 
143 
146  bool LinksLeft();
147 
150  void GoToFirst();
151 
152 
158  void SetDelimiters(const std::string & chars);
159 
160 
161 
162 
163 
164  private:
165  std::string data;
166  std::string delimiters;
167 
168  uint32_t bufferPos;
169  uint32_t links;
170  std::string * cLink;
171 
172  bool curCharGood();
173 };
174 }
175 
176 #endif
void GoToFirst()
Goes back to the first link for reading.
Chain & operator=(const Chain &)
Assign a value to be the Chain.
Allows for easy string building and deconstructing.
Definition: Chain.h:52
3D and 2D positional vector.
Definition: Vector.h:55
const std::string & ToString() const
Returns a std::string equivalent of this Chain.
Definition: Chain.h:100
Chain & operator<<(const Chain &)
Definition: AssetID.h:37
uint32_t GetLinkPos()
Returns the position in the whole string where the current link begins.
bool LinksLeft()
returns if there are any links left
std::string GetLink()
returns the current link;
void SetDelimiters(const std::string &chars)
Set the delimiters to define what each link is composed of. The default delimiters are space...