| Flutter Impeller |

Public Member Functions | Friends | List of all members
impeller::ArchiveLocation Class Reference

`#include <archive_location.h>`

## Public Member Functions
PrimaryKey | GetPrimaryKey () const
template<class T , class = std::enable_if_t<std::is_integral<T>::value>>
bool | Write (const std::string &member, T item)
bool | Write (const std::string &member, double item)
bool | Write (const std::string &member, const std::string &item)
bool | Write (const std::string &member, const Allocation &allocation)
template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool | WriteArchivable (const std::string &member, const T &other)
template<class T , class = std::enable_if_t<std::is_enum<T>::value>>
bool | WriteEnum (const std::string &member, const T &item)
template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool | Write (const std::string &member, const std::vector< T > &items)
template<class T , class = std::enable_if_t<std::is_integral<T>::value>>
bool | Read (const std::string &member, T &item)
bool | Read (const std::string &member, double &item)
bool | Read (const std::string &member, std::string &item)
bool | Read (const std::string &member, Allocation &allocation)
template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool | ReadArchivable (const std::string &member, T &other)
template<class T , class = std::enable_if_t<std::is_enum<T>::value>>
bool | ReadEnum (const std::string &member, T &item)
template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool | Read (const std::string &member, std::vector< T > &items)

## Friends
class | Archive

## Detailed Description

Definition at line 21 of file archive_location.h.

## Member Function Documentation

## ◆ GetPrimaryKey()

PrimaryKey impeller::ArchiveLocation::GetPrimaryKey | ( |  | ) | const

Definition at line 21 of file archive_location.cc.

21 {
22 return primary_key_;
23 }

Referenced by impeller::testing::Sample::Read().

## ◆ Read() [1/5]

bool impeller::ArchiveLocation::Read | ( | const std::string & | member,
|  | Allocation & | allocation
| ) |  |

Definition at line 108 of file archive_location.cc.

108 {
109 auto index = registration_.FindColumnIndex(member);
110 return index.has_value() ? statement_.ReadValue(index.value(), item) : false;
111 }

References impeller::ArchiveClassRegistration::FindColumnIndex(), and impeller::ArchiveStatement::ReadValue().

## ◆ Read() [2/5]

bool impeller::ArchiveLocation::Read | ( | const std::string & | member,
|  | double & | item
| ) |  |

Definition at line 103 of file archive_location.cc.

103 {
104 auto index = registration_.FindColumnIndex(member);
105 return index.has_value() ? statement_.ReadValue(index.value(), item) : false;
106 }

References impeller::ArchiveClassRegistration::FindColumnIndex(), and impeller::ArchiveStatement::ReadValue().

## ◆ Read() [3/5]

bool impeller::ArchiveLocation::Read | ( | const std::string & | member,
|  | std::string & | item
| ) |  |

Definition at line 93 of file archive_location.cc.

93 {
94 auto index = registration_.FindColumnIndex(member);
95 return index.has_value() ? statement_.ReadValue(index.value(), item) : false;
96 }

References impeller::ArchiveClassRegistration::FindColumnIndex(), and impeller::ArchiveStatement::ReadValue().

## ◆ Read() [4/5]

template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>

bool impeller::ArchiveLocation::Read | ( | const std::string & | member,
|  | std::vector< T > & | items
| ) |  |
| inline

Definition at line 111 of file archive_location.h.

111 {
112 /*
113 * From the member, find the foreign key of the vector
114 */
115 int64_t vectorForeignKey = 0;
116 if (!ReadIntegral(member, vectorForeignKey)) {
117 return false;
118 }
119
120 /*
121 * Get vector keys
122 */
123 std::vector<int64_t> keys;
124 if (!ReadVectorKeys(vectorForeignKey, keys)) {
125 return false;
126 }
127
128 const ArchiveDef& otherDef = T::kArchiveDefinition;
129 for (const auto& key : keys) {
130 items.emplace_back();
131
132 if (!context_.UnarchiveInstance(otherDef, key, items.back())) {
133 return false;
134 }
135 }
136
137 return true;
138 }

## ◆ Read() [5/5]

template<class T , class = std::enable_if_t<std::is_integral<T>::value>>

bool impeller::ArchiveLocation::Read | ( | const std::string & | member,
|  | T & | item
| ) |  |
| inline

Definition at line 79 of file archive_location.h.

79 {
80 int64_t decoded = 0;
81 auto result = ReadIntegral(member, decoded);
82 item = static_cast<T>(decoded);
83 return result;
84 }

Referenced by impeller::ArchiveVector::Read(), impeller::testing::Sample::Read(), and impeller::testing::SampleWithVector::Read().

## ◆ ReadArchivable()

template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>

bool impeller::ArchiveLocation::ReadArchivable | ( | const std::string & | member,
|  | T & | other
| ) |  |
| inline

Definition at line 94 of file archive_location.h.

94 {
95 const ArchiveDef& otherDef = T::ArchiveDefinition;
96 return decode(member, otherDef, other);
97 }

## ◆ ReadEnum()

template<class T , class = std::enable_if_t<std::is_enum<T>::value>>

bool impeller::ArchiveLocation::ReadEnum | ( | const std::string & | member,
|  | T & | item
| ) |  |
| inline

Definition at line 100 of file archive_location.h.

100 {
101 int64_t desugared = 0;
102 if (ReadIntegral(member, desugared)) {
103 item = static_cast<T>(desugared);
104 return true;
105 }
106 return false;
107 }

## ◆ Write() [1/5]

bool impeller::ArchiveLocation::Write | ( | const std::string & | member,
|  | const Allocation & | allocation
| ) |  |

Definition at line 41 of file archive_location.cc.

41 {
42 auto index = registration_.FindColumnIndex(member);
43 return index.has_value() ? statement_.WriteValue(index.value(), item) : false;
44 }

References impeller::ArchiveClassRegistration::FindColumnIndex(), and impeller::ArchiveStatement::WriteValue().

## ◆ Write() [2/5]

bool impeller::ArchiveLocation::Write | ( | const std::string & | member,
|  | const std::string & | item
| ) |  |

Definition at line 25 of file archive_location.cc.

26 {
27 auto index = registration_.FindColumnIndex(member);
28 return index.has_value() ? statement_.WriteValue(index.value(), item) : false;
29 }

References impeller::ArchiveClassRegistration::FindColumnIndex(), and impeller::ArchiveStatement::WriteValue().

## ◆ Write() [3/5]

template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>

bool impeller::ArchiveLocation::Write | ( | const std::string & | member,
|  | const std::vector< T > & | items
| ) |  |
| inline

Definition at line 50 of file archive_location.h.

50 {
51 /*
52 * All items in the vector are individually encoded and their keys noted
53 */
54 std::vector<int64_t> members;
55 members.reserve(items.size());
56
57 const ArchiveDef& itemDefinition = T::kArchiveDefinition;
58 for (const auto& item : items) {
59 auto row_id = context_.ArchiveInstance(itemDefinition, item);
60 if (!row_id.has_value()) {
61 return false;
62 }
63 members.emplace_back(row_id.value());
64 }
65
66 /*
67 * The keys are flattened into the vectors table. Write to that table
68 */
69 auto vectorInsert = WriteVectorKeys(std::move(members));
70
71 if (!vectorInsert.has_value()) {
72 return false;
73 }
74
75 return WriteIntegral(member, vectorInsert.value());
76 }

## ◆ Write() [4/5]

bool impeller::ArchiveLocation::Write | ( | const std::string & | member,
|  | double | item
| ) |  |

Definition at line 36 of file archive_location.cc.

36 {
37 auto index = registration_.FindColumnIndex(member);
38 return index.has_value() ? statement_.WriteValue(index.value(), item) : false;
39 }

References impeller::ArchiveClassRegistration::FindColumnIndex(), and impeller::ArchiveStatement::WriteValue().

## ◆ Write() [5/5]

template<class T , class = std::enable_if_t<std::is_integral<T>::value>>

bool impeller::ArchiveLocation::Write | ( | const std::string & | member,
|  | T | item
| ) |  |
| inline

Definition at line 26 of file archive_location.h.

26 {
27 return WriteIntegral(member, static_cast<int64_t>(item));
28 }

Referenced by impeller::ArchiveVector::Write(), impeller::testing::Sample::Write(), impeller::testing::SampleWithVector::Write(), and WriteArchivable().

## ◆ WriteArchivable()

template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>

bool impeller::ArchiveLocation::WriteArchivable | ( | const std::string & | member,
|  | const T & | other
| ) |  |
| inline

Definition at line 38 of file archive_location.h.

38 {
39 const ArchiveDef& otherDef = T::ArchiveDefinition;
40 return Write(member, otherDef, other);
41 }

References Write().

## ◆ WriteEnum()

template<class T , class = std::enable_if_t<std::is_enum<T>::value>>

bool impeller::ArchiveLocation::WriteEnum | ( | const std::string & | member,
|  | const T & | item
| ) |  |
| inline

Definition at line 44 of file archive_location.h.

44 {
45 return WriteIntegral(member, static_cast<int64_t>(item));
46 }

## Friends And Related Function Documentation

## ◆ Archive

friend class Archive
| friend

Definition at line 146 of file archive_location.h.

The documentation for this class was generated from the following files:

- impeller/archivist/archive_location.h
- impeller/archivist/archive_location.cc

impeller::ArchiveStatement::WriteValue
bool WriteValue(size_t index, const std::string &item)
Definition: archive_statement.cc:101
impeller::ArchiveStatement::ReadValue
bool ReadValue(size_t index, T &item)
Definition: archive_statement.h:69
impeller::ArchiveClassRegistration::FindColumnIndex
std::optional< size_t > FindColumnIndex(const std::string &member) const
Definition: archive_class_registration.cc:39
impeller::ArchiveLocation::Write
bool Write(const std::string &member, T item)
Definition: archive_location.h:26