3#ifndef PDFSDK_CXX_TYPES_H_INCLUDED_
4#define PDFSDK_CXX_TYPES_H_INCLUDED_
10#include <pdfsdk/cxx/exception.h>
15inline std::chrono::system_clock::time_point PDDateTimeToStdTimePoint(
const PDDateTime& pddt) {
19 auto time_point = std::chrono::system_clock::from_time_t(std::mktime(&tm));
23 auto utc_offset = std::chrono::hours(pddt.
tz_hour) + std::chrono::minutes(pddt.
tz_minute);
25 ? time_point - utc_offset
26 : time_point + utc_offset;
31template<
typename CallableGetter,
typename... Args>
32std::wstring GetWstringProperty(CallableGetter getter, Args&&... args) {
34 auto ec = std::invoke(getter, args...,
nullptr, 0, &valueSize);
36 return std::wstring{};
38 PDF_CHECK_SUCCESS_X(ec);
39 std::wstring valueString(valueSize, L
'\0');
40 PDF_CHECK_SUCCESS_X(std::invoke(getter, args..., &valueString[0], valueSize, &valueSize));
44template<
typename CallableGetter,
typename... Args>
45std::string GetStringProperty(CallableGetter getter, Args&&... args) {
47 auto ec = std::invoke(getter, args...,
nullptr, 0, &valueSize);
51 PDF_CHECK_SUCCESS_X(ec);
52 std::string valueString(valueSize,
'\0');
53 PDF_CHECK_SUCCESS_X(std::invoke(getter, args..., &valueString[0], valueSize, &valueSize));
@ kPDErrSuccess
Operation was successful.
Definition errors.h:18
@ kPDErrBufferTooSmall
Memory buffer too small, increase buffer size.
Definition errors.h:25
int month
The month in the range 1..12.
Definition types.h:25
int tz_sign
The "sign" of the time zone, (0) means UTC, (-1) is west, (+1) is east.
Definition types.h:30
int year
The year.
Definition types.h:24
int tz_hour
The time zone hour in the range 0..23.
Definition types.h:31
int day
The day of the month in the range 1..31.
Definition types.h:26
int hour
The hour in the range 0..23.
Definition types.h:27
int tz_minute
The time zone minute in the range 0..59.
Definition types.h:32
int second
The second in the range 0..59.
Definition types.h:29
int minute
The minute in the range 0..59.
Definition types.h:28