-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#93 RadosMetadata, rbox_metadata_key
- RadosMetadata moved to separate file rados-metadata.h - enum rbox_metadata_key moved to separate file rados-types.h
- Loading branch information
Showing
5 changed files
with
145 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=8 sw=2 smarttab | ||
/* | ||
* Copyright (c) 2017 Tallence AG and the authors | ||
* | ||
* This is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1, as published by the Free Software | ||
* Foundation. See file COPYING. | ||
*/ | ||
|
||
#ifndef SRC_LIBRMB_RADOS_METADATA_H_ | ||
#define SRC_LIBRMB_RADOS_METADATA_H_ | ||
|
||
#include "rados-types.h" | ||
#include <string> | ||
#include "time.h" | ||
#include <stdlib.h> | ||
#include <rados/librados.hpp> | ||
|
||
namespace librmb { | ||
|
||
class RadosMetadata { | ||
public: RadosMetadata(enum rbox_metadata_key _key, const std::string& val) { convert(_key, val); } | ||
|
||
RadosMetadata(enum rbox_metadata_key _key, const time_t& val) { convert(_key, val); } | ||
|
||
RadosMetadata(enum rbox_metadata_key _key, const char* val) { convert(_key, val); } | ||
|
||
RadosMetadata(enum rbox_metadata_key _key, const uint& val) { convert(_key, val); } | ||
|
||
RadosMetadata(enum rbox_metadata_key _key, const size_t& val) { convert(_key, val); } | ||
|
||
public: | ||
ceph::bufferlist& get_bl(); | ||
std::string& get_key(); | ||
|
||
void convert(const char* value, time_t* t) { | ||
std::istringstream stream(value); | ||
stream >> *t; | ||
} | ||
|
||
public: | ||
ceph::bufferlist bl; | ||
std::string key; | ||
|
||
private: | ||
void convert(enum rbox_metadata_key _key, const std::string& val) { | ||
key = enum_to_string(_key); | ||
bl.append(val); | ||
} | ||
|
||
void convert(enum rbox_metadata_key _key, const time_t& time) { | ||
key = enum_to_string(_key); | ||
bl.append(std::to_string(time)); | ||
} | ||
|
||
void convert(enum rbox_metadata_key _key, char* value) { | ||
key = enum_to_string(_key); | ||
bl.append(value); | ||
} | ||
|
||
void convert(enum rbox_metadata_key _key, const uint& value) { | ||
key = enum_to_string(_key); | ||
bl.append(std::to_string(value)); | ||
} | ||
|
||
void convert(enum rbox_metadata_key _key, const size_t& value) { | ||
key = enum_to_string(_key); | ||
bl.append(std::to_string(static_cast<int>(value))); | ||
} | ||
|
||
std::string enum_to_string(enum rbox_metadata_key _key) { | ||
std::string k(1, static_cast<char>(_key)); | ||
return k; | ||
} | ||
}; | ||
} // end namespace | ||
#endif /* SRC_LIBRMB_RADOS_METADATA_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=8 sw=2 smarttab | ||
/* | ||
* Copyright (c) 2017 Tallence AG and the authors | ||
* | ||
* This is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1, as published by the Free Software | ||
* Foundation. See file COPYING. | ||
*/ | ||
|
||
#ifndef SRC_LIBRMB_RADOS_TYPES_H_ | ||
#define SRC_LIBRMB_RADOS_TYPES_H_ | ||
|
||
namespace librmb { | ||
|
||
enum rbox_metadata_key { | ||
/* | ||
* mailbox global unique id the mail currently is in. | ||
*/ | ||
RBOX_METADATA_MAILBOX_GUID = 'M', | ||
/* Globally unique identifier for the message. Preserved when | ||
copying. */ | ||
RBOX_METADATA_GUID = 'G', | ||
/* POP3 UIDL overriding the default format */ | ||
RBOX_METADATA_POP3_UIDL = 'P', | ||
/* POP3 message ordering (for migrated mails) */ | ||
RBOX_METADATA_POP3_ORDER = 'O', | ||
/* Received UNIX timestamp in hex */ | ||
RBOX_METADATA_RECEIVED_TIME = 'R', | ||
/* Physical message size in hex. Necessary only if it differs from | ||
the dbox_message_header.message_size_hex, for example because the | ||
message is compressed. */ | ||
RBOX_METADATA_PHYSICAL_SIZE = 'Z', | ||
/* Virtual message size in hex (line feeds counted as CRLF) */ | ||
RBOX_METADATA_VIRTUAL_SIZE = 'V', | ||
/* Pointer to external message data. Format is: | ||
1*(<start offset> <byte count> <options> <ref>) */ | ||
RBOX_METADATA_EXT_REF = 'X', | ||
/* Mailbox name where this message was originally saved to. | ||
When rebuild finds a message whose mailbox is unknown, it's | ||
placed to this mailbox. */ | ||
RBOX_METADATA_ORIG_MAILBOX = 'B', | ||
|
||
RBOX_METADATA_MAIL_UID = 'U', | ||
RBOX_METADATA_VERSION = 'I', | ||
/* | ||
* Mails from envelope | ||
*/ | ||
RBOX_METADATA_FROM_ENVELOPE = 'A', | ||
RBOX_METADATA_PVT_FLAGS = 'C', | ||
/* metadata used by old Dovecot versions */ | ||
RBOX_METADATA_OLDV1_EXPUNGED = 'E', | ||
RBOX_METADATA_OLDV1_FLAGS = 'F', | ||
RBOX_METADATA_OLDV1_KEYWORDS = 'K', | ||
RBOX_METADATA_OLDV1_SAVE_TIME = 'S', | ||
RBOX_METADATA_OLDV1_SPACE = ' ' | ||
}; | ||
} // namespace | ||
#endif /* SRC_LIBRMB_RADOS_TYPES_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters