| Flutter Impeller |

Public Member Functions | Static Public Attributes | Friends | List of all members
impeller::ArchiveClassRegistration Class Reference

`#include <archive_class_registration.h>`

## Public Member Functions
bool | IsValid () const
std::optional< size_t > | FindColumnIndex (const std::string &member) const
const std::string & | GetClassName () const
size_t | GetMemberCount () const
ArchiveStatement | CreateInsertStatement () const
ArchiveStatement | CreateQueryStatement (bool single) const

## Static Public Attributes
static constexpr size_t | kPrimaryKeyIndex = 0u

## Friends
class | ArchiveDatabase

## Detailed Description

Definition at line 16 of file archive_class_registration.h.

## Member Function Documentation

## ◆ CreateInsertStatement()

ArchiveStatement impeller::ArchiveClassRegistration::CreateInsertStatement | ( |  | ) | const

Definition at line 109 of file archive_class_registration.cc.

109 {
110 std::stringstream stream;
111 stream << "INSERT OR REPLACE INTO " << definition_.table_name
112 << " VALUES ( ?, ";
113 for (size_t i = 0, columns = definition_.members.size(); i < columns; i++) {
114 stream << "?";
115 if (i != columns - 1) {
116 stream << ", ";
117 }
118 }
119 stream << ");";
120
121 return database_.CreateStatement(stream.str());
122 }

## ◆ CreateQueryStatement()

ArchiveStatement impeller::ArchiveClassRegistration::CreateQueryStatement | ( | bool | single | ) | const

Definition at line 86 of file archive_class_registration.cc.

87 {
88 std::stringstream stream;
89 stream << "SELECT " << kArchivePrimaryKeyColumnName << ", ";
90 for (size_t i = 0, columns = definition_.members.size(); i < columns; i++) {
91 stream << definition_.members[i];
92 if (i != columns - 1) {
93 stream << ",";
94 }
95 }
96 stream << " FROM " << definition_.table_name;
97
98 if (single) {
99 stream << " WHERE " << kArchivePrimaryKeyColumnName << " = ?";
100 } else {
101 stream << " ORDER BY " << kArchivePrimaryKeyColumnName << " ASC";
102 }
103
104 stream << ";";
105
106 return database_.CreateStatement(stream.str());
107 }

References impeller::kArchivePrimaryKeyColumnName.

## ◆ FindColumnIndex()

std::optional< size_t > impeller::ArchiveClassRegistration::FindColumnIndex | ( | const std::string & | member | ) | const

Definition at line 39 of file archive_class_registration.cc.

40 {
41 auto found = column_map_.find(member);
42 if (found == column_map_.end()) {
43 VALIDATION_LOG << "No member named '" << member << "' in class '"
44 << definition_.table_name
45 << "'. Did you forget to register it?";
46 return std::nullopt;
47 }
48 return found->second;
49 }

References VALIDATION_LOG.

Referenced by impeller::ArchiveLocation::Read(), and impeller::ArchiveLocation::Write().

## ◆ GetClassName()

const std::string & impeller::ArchiveClassRegistration::GetClassName | ( |  | ) | const

Definition at line 27 of file archive_class_registration.cc.

27 {
28 return definition_.table_name;
29 }

## ◆ GetMemberCount()

size_t impeller::ArchiveClassRegistration::GetMemberCount | ( |  | ) | const

Definition at line 31 of file archive_class_registration.cc.

31 {
32 return column_map_.size();
33 }

## ◆ IsValid()

bool impeller::ArchiveClassRegistration::IsValid | ( |  | ) | const

Definition at line 35 of file archive_class_registration.cc.

35 {
36 return is_valid_;
37 }

Referenced by impeller::RegistrationIfReady().

## Friends And Related Function Documentation

## ◆ ArchiveDatabase

friend class ArchiveDatabase
| friend

Definition at line 35 of file archive_class_registration.h.

## Member Data Documentation

## ◆ kPrimaryKeyIndex

constexpr size_t impeller::ArchiveClassRegistration::kPrimaryKeyIndex = 0u
| static constexpr

Definition at line 18 of file archive_class_registration.h.

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

- impeller/archivist/archive_class_registration.h
- impeller/archivist/archive_class_registration.cc

impeller::ArchiveDef::table_name
const std::string table_name
Definition: archivable.h:15
impeller::kArchivePrimaryKeyColumnName
static constexpr const char * kArchivePrimaryKeyColumnName
Definition: archive_class_registration.cc:15
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::ArchiveDef::members
const std::vector< std::string > members
Definition: archivable.h:16