Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
- fix, remove, add and edit comments
- enable UML_LOOK in Doxygen
  • Loading branch information
jothepro committed Dec 13, 2021
1 parent c12562e commit 43e03d1
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ GROUP_GRAPHS = YES
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.

UML_LOOK = NO
UML_LOOK = YES

# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
# class node. If there are many fields or methods and many nodes the graph may
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,6 @@ In your Nextcloud installation go to <kbd>settings</kbd> > <kbd>user</kbd> > <k

- Implement equality operators for Cloud, Directory, File
- Add tests for CURL wrapper (e.g. by going against a (mocked?) http server)
- implementing support for big file upload/download (chunked upload/download
- implementing support for big file upload/download (chunked upload/download)
- Improve integration-test coverage
- Improve unit-test coverage
4 changes: 1 addition & 3 deletions lib/include/CloudSync/BasicCredentials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include <memory>

namespace CloudSync {
/**
* @brief Basic access authentication credentials. Used for authorization in webdav & nextcloud.
*/
/// Basic access authentication credentials for authorization in WebDav & Nextcloud.
class BasicCredentials {
public:
virtual ~BasicCredentials() = default;
Expand Down
4 changes: 2 additions & 2 deletions lib/include/CloudSync/Cloud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Directory.hpp"

namespace CloudSync {

/// Provider-independent representation of the connected cloud.
class Cloud {
public:

Expand Down Expand Up @@ -55,4 +55,4 @@ namespace CloudSync {
virtual void logout() = 0;
};

} // namespace CloudSync
}
9 changes: 3 additions & 6 deletions lib/include/CloudSync/CloudFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
#include "OAuth2Credentials.hpp"
#include "BasicCredentials.hpp"



namespace CloudSync {
namespace request {
class Request;
}
/**
* @brief Entrypoint to the library: Create any cloud instance from a given configuration.
*/

/// Entrypoint to the library: Create any cloud instance from a given configuration.
class CloudFactory {
public:
CloudFactory();
Expand Down Expand Up @@ -102,4 +99,4 @@ namespace CloudSync {
std::shared_ptr<request::Request> m_request;
};

} // namespace CloudSync
}
13 changes: 7 additions & 6 deletions lib/include/CloudSync/Directory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

#include "File.hpp"
#include "Resource.hpp"
#include <vector>

namespace CloudSync {
/**
* Provider-independent representation of a directory. Can be seen as a pointer to the actual folder in the cloud. This
* does not hold the contents of the folder in memory but makes a network call each time you ask for a resource.
*/
/**
* @brief Provider-independent representation of a directory.
*
* Can be seen as a pointer to the actual folder in the cloud. This
* does not hold the contents of the folder in memory but makes a network call each time you ask for a resource.
*/
class Directory : public Resource {
public:
/**
Expand Down Expand Up @@ -57,4 +58,4 @@ namespace CloudSync {
*/
virtual std::shared_ptr<File> get_file(const std::filesystem::path &path) const = 0;
};
} // namespace CloudSync
}
18 changes: 14 additions & 4 deletions lib/include/CloudSync/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
#include "Resource.hpp"

namespace CloudSync {
/**
* @brief Provider-independent representation of a file.
*
* Can be seen as a pointer to the actual file in the cloud. This
* does not hold the content of the file in memory but makes a network
* call each time you read the file.
*/
class File : public Resource {
public:

Expand All @@ -13,19 +20,22 @@ namespace CloudSync {
*/
[[nodiscard]] virtual std::string revision() const = 0;

/**
* @return the file content as a string.
*/
/// Read the content of the file into a string.
[[nodiscard]] virtual std::string read() const = 0;

/// Read the content of the file into a binary data-structure.
[[nodiscard]] virtual std::vector<std::uint8_t> read_binary() const = 0;

/**
* @brief Write the content of the file from a string.
* @throws Resource::ResourceHasChanged if the file has changed on the server. Check for a new file version with
* `poll_change()` to resolve this exception.
* @param content New content that should be written to the file. Overrides the existing file content. This may also
* be binary data.
*/
virtual void write(const std::string& content) = 0;

/// Write the content of the file from a binary data-structure.
virtual void write_binary(const std::vector<std::uint8_t>& content) = 0;

/**
Expand All @@ -34,4 +44,4 @@ namespace CloudSync {
*/
virtual bool poll_change() = 0;
};
} // namespace CloudSync
}
1 change: 1 addition & 0 deletions lib/include/CloudSync/OAuth2Credentials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <functional>

namespace CloudSync {
/// OAuth2 credentials for authorization at Dropbox, GDrive, OneDrive
class OAuth2Credentials {
public:
virtual ~OAuth2Credentials() = default;
Expand Down
6 changes: 3 additions & 3 deletions lib/include/CloudSync/Resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>

namespace CloudSync {
/// Common interface for both directories and files
class Resource {
public:

Expand All @@ -23,9 +24,8 @@ namespace CloudSync {
* @note Be aware that deletion a file doesn't always mean it's gone. Most clouds know the concept of a
* recycle bin and will move deleted resources there.
*
* @bug If a directory cannot be removed because it still contains resources, this fails with an undefined behaviour.
* It may for example throw a Cloud::CommunicationError.
* [Help me to improve this](https://gitlab.com/jothepro/libcloudsync)
* @bug If a directory cannot be removed because it still contains resources, this may fail for some cloud providers.
* [Help me to improve this](https://github.com/jothepro/libCloudSync)
*/
virtual void remove() = 0;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/CloudImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ namespace CloudSync {
std::shared_ptr<request::Request> m_request;
std::string m_base_url;
};
} // namespace CloudSync
}
2 changes: 1 addition & 1 deletion lib/src/dropbox/DropboxCloud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ namespace CloudSync::dropbox {

void logout() override;
};
} // namespace CloudSync::dropbox
}
2 changes: 1 addition & 1 deletion lib/src/dropbox/DropboxDirectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ namespace CloudSync::dropbox {
*/
std::shared_ptr<Resource> parseEntry(const json &entry, const std::string &resourceTypeFallback = "") const;
};
} // namespace CloudSync::dropbox
}
2 changes: 1 addition & 1 deletion lib/src/dropbox/DropboxFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ namespace CloudSync::dropbox {
std::shared_ptr<request::Request> prepare_read_request() const;
std::shared_ptr<request::Request> prepare_write_request() const;
};
} // namespace CloudSync::dropbox
}
2 changes: 1 addition & 1 deletion lib/src/gdrive/GDriveCloud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ namespace CloudSync::gdrive {
private:
std::string m_root_name;
};
} // namespace CloudSync::gdrive
}
2 changes: 1 addition & 1 deletion lib/src/gdrive/GDriveDirectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ class GDriveDirectory : public OAuthDirectoryImpl {

bool child_resource_exists(const std::string & resource_name) const;
};
} // namespace CloudSync::gdrive
}
2 changes: 1 addition & 1 deletion lib/src/gdrive/GDriveFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ namespace CloudSync::gdrive {
std::shared_ptr<request::Request> prepare_read_request() const;
std::shared_ptr<request::Request> prepare_write_request() const;
};
} // namespace CloudSync::gdrive
}
2 changes: 1 addition & 1 deletion lib/src/nextcloud/NextcloudCloud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ namespace CloudSync::nextcloud {

void logout() override;
};
} // namespace CloudSync::nextcloud
}

0 comments on commit 43e03d1

Please sign in to comment.