|
4 | 4 | #include <string> |
5 | 5 | #include <vector> |
6 | 6 |
|
| 7 | +#include "firebase/internal/common.h" // For FIREBASE_DEPRECATED_MSG |
| 8 | +#include "firebase/storage/common.h" // For SWIG_STORAGE_EXPORT |
7 | 9 | #include "firebase/storage/storage_reference.h" |
8 | | -#include "app/src/cleanup_notifier.h" // Required for CleanupNotifier |
| 10 | +// No longer include cleanup_notifier directly here, it's an internal detail. |
| 11 | +// No longer forward declare StorageReference if ListResult is now a class with an internal ptr. |
9 | 12 |
|
10 | 13 | namespace firebase { |
11 | 14 | namespace storage { |
12 | 15 |
|
13 | | -// Forward declaration for StorageReference to break circular dependency, |
14 | | -// if StorageReference includes ListResult. |
15 | | -class StorageReference; |
16 | | - |
17 | | -struct ListResult { |
18 | | - ListResult() : items(), prefixes(), page_token() {} |
19 | | - |
20 | | - std::vector<StorageReference> items; |
21 | | - std::vector<StorageReference> prefixes; |
22 | | - std::string page_token; |
23 | | - |
24 | | - // If ListResult itself needs to be managed by CleanupNotifier, |
25 | | - // it would typically be part of a class that inherits from |
26 | | - // firebase::internal::InternalCleanupNotifierInterface. |
27 | | - // For a simple struct like this, direct cleanup management might not be needed |
28 | | - // unless it holds resources that require explicit cleanup. |
29 | | - // However, if it's part of a Future result, the Future's lifecycle |
30 | | - // will be managed. |
31 | | - // For now, we'll keep it simple as per stub requirements. |
32 | | - // If CleanupNotifier is to be used directly with ListResult instances, |
33 | | - // this struct might need to be refactored into a class. |
34 | | - // For now, assuming it's a plain data object. |
| 16 | +// Forward declaration for internal class |
| 17 | +namespace internal { |
| 18 | +class ListResultInternal; |
| 19 | +} // namespace internal |
| 20 | + |
| 21 | +/// @brief Results from a list operation. |
| 22 | +class SWIG_STORAGE_EXPORT ListResult { |
| 23 | + public: |
| 24 | + /// @brief Default constructor. Creates an invalid ListResult. |
| 25 | + ListResult(); |
| 26 | + |
| 27 | + /// @brief Copy constructor. |
| 28 | + /// |
| 29 | + /// @param[in] other ListResult to copy from. |
| 30 | + ListResult(const ListResult& other); |
| 31 | + |
| 32 | + /// @brief Move constructor. |
| 33 | + /// |
| 34 | + /// @param[in] other ListResult to move from. |
| 35 | + ListResult(ListResult&& other); |
| 36 | + |
| 37 | + ~ListResult(); |
| 38 | + |
| 39 | + /// @brief Copy assignment operator. |
| 40 | + /// |
| 41 | + /// @param[in] other ListResult to copy from. |
| 42 | + /// |
| 43 | + /// @return Reference to this ListResult. |
| 44 | + ListResult& operator=(const ListResult& other); |
| 45 | + |
| 46 | + /// @brief Move assignment operator. |
| 47 | + /// |
| 48 | + /// @param[in] other ListResult to move from. |
| 49 | + /// |
| 50 | + /// @return Reference to this ListResult. |
| 51 | + ListResult& operator=(ListResult&& other); |
| 52 | + |
| 53 | + /// @brief Gets the individual items (files) found in this result. |
| 54 | + /// |
| 55 | + /// @return Vector of StorageReferences to the items. Will be empty if |
| 56 | + /// no items are found or if the ListResult is invalid. |
| 57 | + const std::vector<StorageReference>& items() const; |
| 58 | + |
| 59 | + /// @brief Gets the prefixes (directories) found in this result. |
| 60 | + /// These can be used to further "navigate" the storage hierarchy. |
| 61 | + /// |
| 62 | + /// @return Vector of StorageReferences to the prefixes. Will be empty if |
| 63 | + /// no prefixes are found or if the ListResult is invalid. |
| 64 | + const std::vector<StorageReference>& prefixes() const; |
| 65 | + |
| 66 | + /// @brief Gets the page token for the next page of results. |
| 67 | + /// |
| 68 | + /// If empty, there are no more results. |
| 69 | + /// |
| 70 | + /// @return Page token string. |
| 71 | + const std::string& page_token() const; |
| 72 | + |
| 73 | + /// @brief Returns true if this ListResult is valid, false otherwise. |
| 74 | + /// An invalid ListResult is one that has not been initialized or has |
| 75 | + /// been moved from. |
| 76 | + bool is_valid() const; |
| 77 | + |
| 78 | + private: |
| 79 | + friend class StorageReference; // Allows StorageReference to construct ListResult |
| 80 | + friend class internal::StorageReferenceInternal; // Allow internal classes to construct |
| 81 | + |
| 82 | + // Constructor for internal use, takes ownership of the internal object. |
| 83 | + explicit ListResult(internal::ListResultInternal* internal_list_result); |
| 84 | + |
| 85 | + // Using firebase::internal::InternalUniquePtr for managing the lifecycle |
| 86 | + // of the internal object, ensuring it's cleaned up properly. |
| 87 | + ::firebase::internal::InternalUniquePtr<internal::ListResultInternal> internal_; |
| 88 | + |
| 89 | + // Static empty results to return for invalid ListResult objects |
| 90 | + static const std::vector<StorageReference> s_empty_items_; |
| 91 | + static const std::vector<StorageReference> s_empty_prefixes_; |
| 92 | + static const std::string s_empty_page_token_; |
35 | 93 | }; |
36 | 94 |
|
37 | 95 | } // namespace storage |
|
0 commit comments