MyraMath
Checksum.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_IO_CHECKSUM_H
7 #define MYRAMATH_IO_CHECKSUM_H
8 
14 #include <myramath/MYRAMATH_EXPORT.h>
15 #include <myramath/io/Streams.h>
16 
17 #include <string>
18 
19 namespace myra {
20 
22 class MYRAMATH_EXPORT Checksum
23  {
24  public:
25 
27  Checksum(const std::string& in_s)
28  : s(in_s) { }
29 
31  const std::string& str() const
32  { return s; }
33 
35  static int MAGIC()
36  { return 0x6172796d; }
37 
38  private:
39 
40  // Holds check string.
41  std::string s;
42 
43  };
44 
46 MYRAMATH_EXPORT Checksum checksum(const std::string& s);
47 
49 // usage: out << checksum("MyType")
50 MYRAMATH_EXPORT OutputStream& operator<< (OutputStream& out, const Checksum& c);
51 
53 // usage: in >> checksum("MyType")
54 MYRAMATH_EXPORT InputStream& operator>> (InputStream& in, const Checksum& c);
55 
56 } // namespace
57 
58 #endif
const std::string & str() const
Inspects given string.
Definition: Checksum.h:31
Checksum(const std::string &in_s)
Constructor, requires a std::string.
Definition: Checksum.h:27
static int MAGIC()
Returns a sentinel int used to mark off a checksum.
Definition: Checksum.h:35
Definition: syntax.dox:1
Abstraction layer, serializable objects write themselves to these.
Definition: Streams.h:39
Abstraction layer, deserializable objects read themselves from these.
Definition: Streams.h:47
Implementation detail, wraps a std::string into a Checksum type.
Definition: Checksum.h:22
Bases classes for binary input/output streams.