const std::string indexFilename("buckets");
const std::string guardFilename("guard");
const std::string checksumFilename("checksum");
-const std::string bucketFilenamePrefix("_");
const std::string backupFilenameSuffix("~");
+const std::string bucketFilenamePrefix("_");
+const char fieldSeparator(';');
+const char recordSeparator('\n');
} // namespace StoragePath
namespace PluginPath {
extern const std::string indexFilename;
extern const std::string guardFilename;
extern const std::string checksumFilename;
-extern const std::string bucketFilenamePrefix;
extern const std::string backupFilenameSuffix;
+extern const std::string bucketFilenamePrefix;
+extern const char fieldSeparator;
+extern const char recordSeparator;
} // namespace StoragePath
namespace PluginPath {
* @brief Parses policies from input stream
*/
+#include <config/PathConfig.h>
#include <exceptions/BucketRecordCorruptedException.h>
#include <storage/StorageDeserializer.h>
-#include <storage/StorageSerializer.h>
#include "AdminPolicyParser.h"
CynaraAdminPolicies policies;
auto nextToken = [] (const std::string &line, std::size_t &beginToken) -> std::string {
- auto endToken = line.find(StorageSerializer::fieldSeparator(), beginToken);
+ auto endToken = line.find(PathConfig::StoragePath::fieldSeparator, beginToken);
if (endToken != std::string::npos) {
auto token = line.substr(beginToken, endToken - beginToken);
beginToken = endToken + 1;
for (std::size_t lineNum = 1; !input->eof(); ++lineNum) {
std::string line;
- std::getline(*input, line, StorageSerializer::recordSeparator());
+ std::getline(*input, line, PathConfig::StoragePath::recordSeparator);
if (line.empty())
break;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <string>
#include <vector>
+#include <config/PathConfig.h>
#include <exceptions/BucketRecordCorruptedException.h>
#include <types/PolicyCollection.h>
#include <types/PolicyResult.h>
#include <types/PolicyType.h>
#include <storage/StorageDeserializer.h>
-#include <storage/StorageSerializer.h>
#include "BucketDeserializer.h"
// TODO: Get someone smart to do error checking on stream
for (std::size_t lineNum = 1; !m_inStream->eof(); ++lineNum) {
std::string line;
- std::getline(*m_inStream, line, StorageSerializer::recordSeparator());
+ std::getline(*m_inStream, line, PathConfig::StoragePath::recordSeparator);
if (line.empty())
break;
std::array<std::string, 3> keyFeatures;
for (std::size_t tokenNum = 0; tokenNum < keyFeatures.size(); ++tokenNum) {
- auto endToken = line.find(StorageSerializer::fieldSeparator(), beginToken);
+ auto endToken = line.find(PathConfig::StoragePath::fieldSeparator, beginToken);
if (endToken != std::string::npos) {
keyFeatures[tokenNum] = line.substr(beginToken, endToken - beginToken);
beginToken = endToken + 1;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <memory>
#include <string>
+#include <config/PathConfig.h>
#include <exceptions/BucketDeserializationException.h>
#include <exceptions/BucketRecordCorruptedException.h>
#include <types/PolicyType.h>
#include <storage/BucketDeserializer.h>
#include <storage/Buckets.h>
-#include <storage/StorageSerializer.h>
#include "StorageDeserializer.h"
for (std::size_t lineNum = 1; !m_inStream->eof(); ++lineNum) {
std::string line;
- std::getline(*m_inStream, line, StorageSerializer::recordSeparator());
+ std::getline(*m_inStream, line, PathConfig::StoragePath::recordSeparator);
if (line.empty())
break;
PolicyBucketId StorageDeserializer::parseBucketId(const std::string &line,
std::size_t &beginToken) {
- auto bucketNameEndToken = line.find(StorageSerializer::fieldSeparator(), beginToken);
+ auto bucketNameEndToken = line.find(PathConfig::StoragePath::fieldSeparator, beginToken);
if (bucketNameEndToken != std::string::npos) {
auto bucketName = line.substr(beginToken, bucketNameEndToken - beginToken);
beginToken = bucketNameEndToken + 1;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
namespace Cynara {
-char StorageSerializer::m_fieldSeparator = ';';
-char StorageSerializer::m_recordSeparator = '\n';
-
StorageSerializer::StorageSerializer(std::shared_ptr<std::ostream> os) : m_outStream(os) {
}
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <fstream>
#include <memory>
+#include <config/PathConfig.h>
#include <types/PolicyBucket.h>
#include <types/PolicyBucketId.h>
#include <types/PolicyCollection.h>
inline void dumpFields(const Arg1 &arg1, const Args&... args) {
dump(arg1);
if (sizeof...(Args) > 0) {
- *m_outStream << fieldSeparator();
+ *m_outStream << PathConfig::StoragePath::fieldSeparator;
}
dumpFields(args...);
}
inline void dumpFields(void) {
- *m_outStream << recordSeparator();
+ *m_outStream << PathConfig::StoragePath::recordSeparator;
}
void dump(const PolicyKeyFeature &keyFeature);
private:
std::shared_ptr<std::ostream> m_outStream;
-
- static char m_fieldSeparator;
- static char m_recordSeparator;
-
-public:
- static const char &fieldSeparator(void) {
- return m_fieldSeparator;
- }
-
- static const char &recordSeparator(void) {
- return m_recordSeparator;
- }
};
} /* namespace Cynara */