OnixS C++ FIX Engine  4.12.0
API Documentation
SecureString.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
4 *
5 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
6 * and international copyright treaties.
7 *
8 * Access to and use of the software is governed by the terms of the applicable OnixS Software
9 * Services Agreement (the Agreement) and Customer end user license agreements granting
10 * a non-assignable, non-transferable and non-exclusive license to use the software
11 * for it's own data processing purposes under the terms defined in the Agreement.
12 *
13 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
14 * of this source code or associated reference material to any other location for further reproduction
15 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
16 *
17 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18 * the terms of the Agreement is a violation of copyright law.
19 */
20 
21 #include <OnixS/FIXEngine/ABI.h>
22 
24 
25 namespace OnixS {
26 namespace Cryptography {
27 
28 /// The immutable secure string
30 {
31 public:
32  /// Constructs the empty SecureString.
33  SecureString();
34 
35  /// Constructs the SecureString which stores the encrypted plainText.
36  ///
37  /// @param plainText The plain text to be encrypted and stored.
38  explicit SecureString(FIX::StringRef plainText);
39 
40  /// Constructs the SecureString which stores the encrypted plainText.
41  ///
42  /// @param plainText The plain text to be encrypted and stored.
43  /// @param plainTextLength The plain text length.
44  SecureString(const char * plainText, size_t plainTextLength);
45 
46  /// Initializes the instance as a shallow copy of other one.
47  SecureString(const SecureString & other);
48 
49  /// Makes a shallow copy of another SecureString.
50  SecureString & operator=(const SecureString & other);
51 
52  /// Disposes all internal data structures.
53  ~SecureString();
54 
55  /// The length of the plain string.
56  size_t length() const;
57 
58  /// Indicates whether the SecureString has no data.
59  bool empty() const;
60 
61 protected:
62  class Impl;
63  SecureString(const Impl *);
64 
65 private:
66  const Impl * impl_;
67 };
68 
69 /// The editable secure string.
71 {
72 public:
73  /// Constructs the empty SecureStringBuilder.
74  explicit SecureStringBuilder();
75 
76  /// Constructs the SecureStringBuilder which stores the encrypted plainText as an initial value.
77  ///
78  /// @param plainText The plain text to be encrypted and stored.
79  explicit SecureStringBuilder(FIX::StringRef plainText);
80 
81  /// Constructs the SecureStringBuilder which stores the encrypted plainText as an initial value.
82  ///
83  /// @param plainText The plain text to be encrypted and stored.
84  /// @param plainTextLength The plain text length.
85  SecureStringBuilder(const char * plainText, size_t plainTextLength);
86 
87  /// Initializes the instance as a deep copy of other one.
89 
90  /// Makes a deep copy of another SecureStringBuilder.
91  SecureStringBuilder & operator=(const SecureStringBuilder & other);
92 
94 
95  /// Gets the number of characters in the current secure string.
96  size_t length() const;
97 
98  /// Moves the encoded data to the immutable SecureString object.
99  ///
100  /// SecureStringBuilder becomes empty after detaching.
101  SecureString detach();
102 
103  /// Replaces the secure value with a new one.
104  ///
105  /// @param plainText plain text to be encrypted and stored.
106  void assign(FIX::StringRef plainText);
107 
108  /// Replaces internal value with a new one.
109  ///
110  /// @param plainText The plain text to be encrypted and stored.
111  /// @param plainTextLength The plain text length.
112  void assign(const char * plainText, size_t plainTextLength);
113 
114  /// Appends a character to the end of the current secure string.
115  void append(char c);
116 
117  /// Inserts a character in this secure string at the specified index position.
118  void insert(size_t index, char c);
119 
120  /// Replaces the existing character at the specified index position with another character.
121  void replace(size_t index, char c);
122 
123  /// Removes the character at the specified index position from this secure string.
124  void erase(size_t index);
125 
126  /// Deletes the value of the current secure string.
127  void clear();
128 
129 protected:
130  class Impl;
131 
132 private:
133  Impl * impl_;
134 };
135 
136 
137 }
138 }
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
Provides an efficient way of accessing text-based FIX field values.
Definition: StringRef.h:59
virtual void clear()=0
Clears the storage.
The editable secure string.
Definition: SecureString.h:70
The immutable secure string.
Definition: SecureString.h:29