Move definition of types into DesktopFile

Types will be shared with future DesktopFileWriter class.
This commit is contained in:
TheAssassin
2018-11-09 02:26:09 +01:00
parent be1b2c95d4
commit 8a2d57e8d5
5 changed files with 20 additions and 16 deletions
+12 -1
View File
@@ -1,8 +1,12 @@
// system includes
#include <unordered_map>
// library includes
#include <boost/filesystem.hpp>
// local includes
#include "desktopfileentry.h"
#pragma once
namespace linuxdeploy {
@@ -12,7 +16,14 @@ namespace linuxdeploy {
* Parse and read desktop files.
*/
class DesktopFile {
private:
public:
// describes a single section
typedef std::unordered_map<std::string, DesktopFileEntry> section_t;
// describes all sections in the desktop file
typedef std::unordered_map<std::string, section_t> sections_t;
private:
// private data class pattern
class PrivateData;
PrivateData* d;
+4 -4
View File
@@ -6,7 +6,7 @@
// local headers
#include "linuxdeploy/util/util.h"
#include "desktopfileentry.h"
#include "linuxdeploy/core/desktopfileentry.h"
#include "desktopfilereader.h"
namespace bf = boost::filesystem;
@@ -17,7 +17,7 @@ namespace linuxdeploy {
class DesktopFileReader::PrivateData {
public:
bf::path path;
sections_t sections;
DesktopFile::sections_t sections;
public:
bool isEmpty() {
@@ -59,7 +59,7 @@ namespace linuxdeploy {
auto title = line.substr(1, line.find(']') - 1);
// set up the new section
sections.insert(std::make_pair(title, section_t()));
sections.insert(std::make_pair(title, DesktopFile::section_t()));
currentSectionName = std::move(title);
} else {
// we require at least one section to be present in the desktop file
@@ -146,7 +146,7 @@ namespace linuxdeploy {
return d->path;
}
DesktopFileReader::section_t DesktopFileReader::operator[](const std::string& name) {
DesktopFile::section_t DesktopFileReader::operator[](const std::string& name) {
auto it = d->sections.find(name);
// the map would lazy-initialize a new entry in case the section doesn't exist
+3 -10
View File
@@ -3,13 +3,13 @@
// system includes
#include <istream>
#include <memory>
#include <unordered_map>
// library includes
#include <boost/filesystem.hpp>
#include <linuxdeploy/core/desktopfile.h>
// local includes
#include "desktopfileentry.h"
#include "linuxdeploy/core/desktopfileentry.h"
namespace linuxdeploy {
namespace core {
@@ -21,13 +21,6 @@ namespace linuxdeploy {
std::shared_ptr<PrivateData> d;
public:
// describes a single section
typedef std::unordered_map<std::string, DesktopFileEntry> section_t;
// describes all sections in the desktop file
typedef std::unordered_map<std::string, section_t> sections_t;
public:
// default constructor
DesktopFileReader();
@@ -62,7 +55,7 @@ namespace linuxdeploy {
// get a specific section from the parsed data
// throws std::range_error if section does not exist
section_t operator[](const std::string& name);
DesktopFile::section_t operator[](const std::string& name);
};
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
#include <boost/lexical_cast.hpp>
// local headers
#include "../../src/core/desktopfileentry.h"
#include "linuxdeploy/core/desktopfileentry.h"
using boost::bad_lexical_cast;
using namespace linuxdeploy::core::desktopfile;