bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitpropvariant.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) Riccardo Ostani - All Rights Reserved.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef BITPROPVARIANT_HPP
11#define BITPROPVARIANT_HPP
12
13#include "bitdefines.hpp"
14#include "bittypes.hpp"
15#include "bitwindows.hpp"
16
17#include <chrono>
18#include <cstdint>
19#include <string>
20#include <type_traits>
21
22namespace bit7z {
23
28
130
139
157
161struct BitPropVariant final : PROPVARIANT {
165 BitPropVariant() noexcept;
166
173
179 BitPropVariant( BitPropVariant&& other ) noexcept;
180
186 explicit BitPropVariant( bool value ) noexcept;
187
193 explicit BitPropVariant( const sevenzip_string::value_type* value );
194
200 explicit BitPropVariant( const sevenzip_string& value );
201
207 explicit BitPropVariant( std::uint8_t value ) noexcept;
208
214 explicit BitPropVariant( std::uint16_t value ) noexcept;
215
221 explicit BitPropVariant( std::uint32_t value ) noexcept;
222
228 explicit BitPropVariant( std::uint64_t value ) noexcept;
229
235 explicit BitPropVariant( std::int8_t value ) noexcept;
236
242 explicit BitPropVariant( std::int16_t value ) noexcept;
243
249 explicit BitPropVariant( std::int32_t value ) noexcept;
250
256 explicit BitPropVariant( std::int64_t value ) noexcept;
257
263 explicit BitPropVariant( FILETIME value ) noexcept;
264
271
279 auto operator=( const BitPropVariant& other ) -> BitPropVariant&;
280
288 auto operator=( BitPropVariant&& other ) noexcept -> BitPropVariant&;
289
299 template< typename T >
300 auto operator=( const T& value ) noexcept( std::is_integral< T >::value ) -> BitPropVariant& {
301 *this = BitPropVariant{ value };
302 return *this;
303 }
304
309 BIT7Z_NODISCARD auto getBool() const -> bool;
310
315 BIT7Z_NODISCARD auto getString() const -> tstring;
316
321 BIT7Z_NODISCARD auto getNativeString() const -> native_string;
322
327 BIT7Z_NODISCARD auto getRawString() const -> sevenzip_string;
328
333 BIT7Z_NODISCARD auto getUInt8() const -> std::uint8_t;
334
339 BIT7Z_NODISCARD auto getUInt16() const -> std::uint16_t;
340
345 BIT7Z_NODISCARD auto getUInt32() const -> std::uint32_t;
346
351 BIT7Z_NODISCARD auto getUInt64() const -> std::uint64_t;
352
357 BIT7Z_NODISCARD auto getInt8() const -> std::int8_t;
358
363 BIT7Z_NODISCARD auto getInt16() const -> std::int16_t;
364
369 BIT7Z_NODISCARD auto getInt32() const -> std::int32_t;
370
375 BIT7Z_NODISCARD auto getInt64() const -> std::int64_t;
376
381 BIT7Z_NODISCARD auto getFileTime() const -> FILETIME;
382
387 BIT7Z_NODISCARD auto getTimePoint() const -> time_type;
388
392 BIT7Z_NODISCARD auto toString() const -> tstring;
393
397 BIT7Z_NODISCARD auto isEmpty() const noexcept -> bool;
398
402 BIT7Z_NODISCARD auto isBool() const noexcept -> bool;
403
407 BIT7Z_NODISCARD auto isString() const noexcept -> bool;
408
412 BIT7Z_NODISCARD auto isUInt8() const noexcept -> bool;
413
417 BIT7Z_NODISCARD auto isUInt16() const noexcept -> bool;
418
422 BIT7Z_NODISCARD auto isUInt32() const noexcept -> bool;
423
427 BIT7Z_NODISCARD auto isUInt64() const noexcept -> bool;
428
432 BIT7Z_NODISCARD auto isInt8() const noexcept -> bool;
433
437 BIT7Z_NODISCARD auto isInt16() const noexcept -> bool;
438
442 BIT7Z_NODISCARD auto isInt32() const noexcept -> bool;
443
447 BIT7Z_NODISCARD auto isInt64() const noexcept -> bool;
448
452 BIT7Z_NODISCARD auto isFileTime() const noexcept -> bool;
453
457 BIT7Z_NODISCARD auto type() const -> BitPropVariantType;
458
462 void clear() noexcept;
463
464 private:
465 void internalClear() noexcept;
466};
467
476auto operator==( const BitPropVariant& lhs, const BitPropVariant& rhs ) noexcept -> bool;
477
486auto operator!=( const BitPropVariant& lhs, const BitPropVariant& rhs ) noexcept -> bool;
487
488} // namespace bit7z
489
490#endif // BITPROPVARIANT_HPP
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:29
BitProperty
The BitProperty enum represents the archive/item properties that 7-zip can read or write.
Definition bitpropvariant.hpp:32
@ IsAltStream
Whether the item is an alternate data stream.
Definition bitpropvariant.hpp:96
@ Group
The group owning the item.
Definition bitpropvariant.hpp:59
@ UnpackVer
The format version required to extract the item.
Definition bitpropvariant.hpp:66
@ Comment
The comment associated with the item.
Definition bitpropvariant.hpp:61
@ AltStreamsSize
The total size of the alternate data streams of the item.
Definition bitpropvariant.hpp:109
@ Attrib
The attributes of the item.
Definition bitpropvariant.hpp:42
@ OutName
The suggested output name for the item.
Definition bitpropvariant.hpp:127
@ Warning
A warning associated with the archive.
Definition bitpropvariant.hpp:106
@ ReadOnly
Whether the item is read-only.
Definition bitpropvariant.hpp:126
@ ATime
The last access time of the item.
Definition bitpropvariant.hpp:44
@ Sha256
The SHA-256 hash of the item.
Definition bitpropvariant.hpp:101
@ TotalPhySize
The total physical size of the multi-volume archive.
Definition bitpropvariant.hpp:112
@ ErrorFlags
The flags describing the errors detected while opening the archive.
Definition bitpropvariant.hpp:104
@ MTime
The last write time of the item.
Definition bitpropvariant.hpp:45
@ CRC
The CRC checksum of the item.
Definition bitpropvariant.hpp:52
@ DictionarySize
The dictionary size used to compress the item.
Definition bitpropvariant.hpp:51
@ TimeType
The type (precision) of the item timestamps.
Definition bitpropvariant.hpp:73
@ Provider
The provider of the item.
Definition bitpropvariant.hpp:94
@ Va
The virtual address of the item.
Definition bitpropvariant.hpp:81
@ BigEndian
Whether the values are stored in big-endian byte order.
Definition bitpropvariant.hpp:75
@ IsTree
Whether the archive items are organized as a tree.
Definition bitpropvariant.hpp:99
@ MainSubfile
The index of the main subfile of the archive.
Definition bitpropvariant.hpp:34
@ NtSecure
The NT security descriptor of the item.
Definition bitpropvariant.hpp:95
@ NumBlocks
The number of blocks in the archive.
Definition bitpropvariant.hpp:71
@ IsAnti
Whether the item is an anti-item (a deletion marker).
Definition bitpropvariant.hpp:54
@ NumSubDirs
The number of subdirectories contained in the item.
Definition bitpropvariant.hpp:64
@ Characts
The characteristics of the item.
Definition bitpropvariant.hpp:80
@ NtReparse
The NT reparse point data of the item.
Definition bitpropvariant.hpp:122
@ ClusterSize
The cluster size of the volume.
Definition bitpropvariant.hpp:91
@ SplitBefore
Whether the item is continued from a previous volume.
Definition bitpropvariant.hpp:49
@ Id
The identifier of the item.
Definition bitpropvariant.hpp:82
@ Name
The name of the item.
Definition bitpropvariant.hpp:37
@ IsDir
Whether the item is a directory.
Definition bitpropvariant.hpp:39
@ Method
The compression method used for the item.
Definition bitpropvariant.hpp:55
@ IsVolume
Whether the archive is a multi-volume archive.
Definition bitpropvariant.hpp:68
@ Position
The position of the item.
Definition bitpropvariant.hpp:62
@ Cpu
The target CPU architecture.
Definition bitpropvariant.hpp:76
@ IsNotArcType
Whether the file is not of the detected archive type.
Definition bitpropvariant.hpp:117
@ PosixAttrib
The POSIX attributes of the item.
Definition bitpropvariant.hpp:86
@ TailSize
The size of the data following the archive (tail).
Definition bitpropvariant.hpp:120
@ Extension
The file extension of the item.
Definition bitpropvariant.hpp:38
@ SymLink
The symbolic link target of the item.
Definition bitpropvariant.hpp:87
@ ZerosTailIsAllowed
Whether a tail of zero bytes is allowed after the archive data.
Definition bitpropvariant.hpp:119
@ SplitAfter
Whether the item is continued in the next volume.
Definition bitpropvariant.hpp:50
@ NumErrors
The number of errors detected in the archive.
Definition bitpropvariant.hpp:103
@ WarningFlags
The flags describing the warnings detected while opening the archive.
Definition bitpropvariant.hpp:105
@ NumVolumes
The number of volumes composing the archive.
Definition bitpropvariant.hpp:72
@ Size
The uncompressed size of the item.
Definition bitpropvariant.hpp:40
@ Prefix
The path prefix of the item.
Definition bitpropvariant.hpp:63
@ VolumeName
The label of the volume.
Definition bitpropvariant.hpp:92
@ PhySize
The physical size of the archive.
Definition bitpropvariant.hpp:77
@ UnpackSize
The uncompressed size of the archive.
Definition bitpropvariant.hpp:111
@ ErrorType
The type of error detected while opening the archive.
Definition bitpropvariant.hpp:102
@ StreamId
The identifier of the data stream of the item.
Definition bitpropvariant.hpp:125
@ Sha1
The SHA-1 hash of the item.
Definition bitpropvariant.hpp:100
@ Checksum
The checksum of the item.
Definition bitpropvariant.hpp:79
@ PackSize
The compressed size of the item.
Definition bitpropvariant.hpp:41
@ HardLink
The hard link target of the item.
Definition bitpropvariant.hpp:123
@ HeadersSize
The size of the archive headers.
Definition bitpropvariant.hpp:78
@ User
The user owning the item.
Definition bitpropvariant.hpp:58
@ Error
An error associated with the item.
Definition bitpropvariant.hpp:88
@ Commented
Whether the item has a comment.
Definition bitpropvariant.hpp:47
@ HostOS
The host OS on which the item was created.
Definition bitpropvariant.hpp:56
@ Type
The type of the item.
Definition bitpropvariant.hpp:53
@ NumStreams
The number of streams in the archive.
Definition bitpropvariant.hpp:107
@ FreeSpace
The free space available on the volume.
Definition bitpropvariant.hpp:90
@ CreatorApp
The application that created the archive.
Definition bitpropvariant.hpp:84
@ Path
The path of the item.
Definition bitpropvariant.hpp:36
@ CopyLink
The copy link of the item.
Definition bitpropvariant.hpp:128
@ LocalName
The local name of the item.
Definition bitpropvariant.hpp:93
@ VolumeIndex
The index of the volume containing the item.
Definition bitpropvariant.hpp:113
@ Volume
The volume the item belongs to.
Definition bitpropvariant.hpp:67
@ Links
The number of hard links to the item.
Definition bitpropvariant.hpp:70
@ SubType
The subtype of the archive.
Definition bitpropvariant.hpp:114
@ CodePage
The code page used to encode the item.
Definition bitpropvariant.hpp:116
@ INode
The inode number of the item.
Definition bitpropvariant.hpp:124
@ IsDeleted
Whether the item is marked as deleted.
Definition bitpropvariant.hpp:98
@ ShortName
The short (DOS 8.3) name of the item.
Definition bitpropvariant.hpp:83
@ PhySizeCantBeDetected
Whether the physical size of the archive cannot be detected.
Definition bitpropvariant.hpp:118
@ Encrypted
Whether the item is encrypted.
Definition bitpropvariant.hpp:48
@ Offset
The offset of the item.
Definition bitpropvariant.hpp:69
@ Bit64
Whether the archive uses 64-bit values.
Definition bitpropvariant.hpp:74
@ Block
The index of the block containing the item.
Definition bitpropvariant.hpp:60
@ IsAux
Whether the item is an auxiliary item.
Definition bitpropvariant.hpp:97
@ FileSystem
The file system on which the item was stored.
Definition bitpropvariant.hpp:57
@ Solid
Whether the item uses solid compression.
Definition bitpropvariant.hpp:46
@ NumAltStreams
The number of alternate data streams of the item.
Definition bitpropvariant.hpp:108
@ SectorSize
The sector size of the volume.
Definition bitpropvariant.hpp:85
@ NoProperty
No property (placeholder for an invalid or unset property).
Definition bitpropvariant.hpp:33
@ VirtualSize
The virtual size of the item.
Definition bitpropvariant.hpp:110
@ TotalSize
The total size of the volume.
Definition bitpropvariant.hpp:89
@ EmbeddedStubSize
The size of the executable stub embedded before the archive data.
Definition bitpropvariant.hpp:121
@ HandlerItemIndex
The internal item index used by the archive handler.
Definition bitpropvariant.hpp:35
@ ShortComment
A short comment describing the archive.
Definition bitpropvariant.hpp:115
@ NumSubFiles
The number of subfiles contained in the item.
Definition bitpropvariant.hpp:65
@ CTime
The creation time of the item.
Definition bitpropvariant.hpp:43
std::wstring sevenzip_string
The string type used internally by 7-Zip.
Definition bittypes.hpp:69
auto to_string(BitProperty property) -> std::string
Returns the name of the given archive/item property.
BitPropVariantType
The BitPropVariantType enum represents the possible types that a BitPropVariant can store.
Definition bitpropvariant.hpp:143
@ String
String BitPropVariant type.
Definition bitpropvariant.hpp:146
@ Int16
16-bit signed int BitPropVariant type
Definition bitpropvariant.hpp:152
@ FileTime
FILETIME BitPropVariant type.
Definition bitpropvariant.hpp:155
@ Int8
8-bit signed int BitPropVariant type
Definition bitpropvariant.hpp:151
@ UInt16
16-bit unsigned int BitPropVariant type
Definition bitpropvariant.hpp:148
@ UInt64
64-bit unsigned int BitPropVariant type
Definition bitpropvariant.hpp:150
@ UInt8
8-bit unsigned int BitPropVariant type
Definition bitpropvariant.hpp:147
@ Int32
32-bit signed int BitPropVariant type
Definition bitpropvariant.hpp:153
@ Bool
Boolean BitPropVariant type.
Definition bitpropvariant.hpp:145
@ Empty
Empty BitPropVariant type.
Definition bitpropvariant.hpp:144
@ UInt32
32-bit unsigned int BitPropVariant type
Definition bitpropvariant.hpp:149
@ Int64
64-bit signed int BitPropVariant type
Definition bitpropvariant.hpp:154
std::basic_string< tchar > tstring
Definition bittypes.hpp:104
std::chrono::time_point< std::chrono::system_clock > time_type
A type representing a time point measured using the system clock.
Definition bitpropvariant.hpp:27
std::string native_string
Native string type of the system.
Definition bittypes.hpp:80
The BitPropVariant struct is a light extension to the WinAPI PROPVARIANT struct providing useful gett...
Definition bitpropvariant.hpp:161
void clear() noexcept
Clears the current value of the variant object.
auto getTimePoint() const -> time_type
auto isInt8() const noexcept -> bool
auto isString() const noexcept -> bool
auto getInt16() const -> std::int16_t
auto getInt64() const -> std::int64_t
auto isInt64() const noexcept -> bool
auto getFileTime() const -> FILETIME
auto getUInt32() const -> std::uint32_t
auto getInt8() const -> std::int8_t
auto getBool() const -> bool
auto getInt32() const -> std::int32_t
auto toString() const -> tstring
auto getString() const -> tstring
auto isUInt32() const noexcept -> bool
auto isInt16() const noexcept -> bool
auto isBool() const noexcept -> bool
auto getNativeString() const -> native_string
auto getRawString() const -> sevenzip_string
auto getUInt64() const -> std::uint64_t
auto type() const -> BitPropVariantType
auto getUInt8() const -> std::uint8_t
auto isUInt64() const noexcept -> bool
auto isInt32() const noexcept -> bool
BitPropVariant() noexcept
Constructs an empty BitPropVariant object.
auto isUInt8() const noexcept -> bool
auto isEmpty() const noexcept -> bool
auto getUInt16() const -> std::uint16_t
auto isFileTime() const noexcept -> bool
auto isUInt16() const noexcept -> bool