chromium/third_party/pdfium/xfa/fgas/crt/cfgas_stringformatter.cpp

// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "xfa/fgas/crt/cfgas_stringformatter.h"

#include <math.h>

#include <algorithm>
#include <limits>
#include <utility>
#include <vector>

#include "core/fxcrt/cfx_datetime.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/containers/contains.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/stl_util.h"
#include "xfa/fgas/crt/cfgas_decimal.h"
#include "xfa/fgas/crt/locale_mgr_iface.h"

// NOTE: Code uses the convention for backwards-looping with unsigned types
// that exploits the well-defined behaviour for unsigned underflow (and hence
// the standard x < size() can be used in all cases to validate indices).

#define FX_NUMSTYLE_Percent
#define FX_NUMSTYLE_Exponent
#define FX_NUMSTYLE_DotVorv

namespace {

struct LocaleDateTimeSubcategoryWithHash {};

struct LocaleNumberSubcategoryWithHash {};

#undef SUBC
#define SUBC
constexpr LocaleDateTimeSubcategoryWithHash kLocaleDateTimeSubcategoryData[] =;

constexpr LocaleNumberSubcategoryWithHash kLocaleNumSubcategoryData[] =;
#undef SUBC

struct FX_LOCALETIMEZONEINFO {};

constexpr auto kFXLocaleTimeZoneData =;

constexpr wchar_t kTimeSymbols[] =;
constexpr wchar_t kDateSymbols[] =;
constexpr wchar_t kConstChars[] =;

constexpr wchar_t kDateStr[] =;
constexpr wchar_t kTimeStr[] =;
constexpr wchar_t kDateTimeStr[] =;
constexpr wchar_t kNumStr[] =;
constexpr wchar_t kTextStr[] =;
constexpr wchar_t kZeroStr[] =;
constexpr wchar_t kNullStr[] =;

size_t ParseTimeZone(pdfium::span<const wchar_t> spStr, int* tz) {}

int32_t ConvertHex(int32_t iKeyValue, wchar_t ch) {}

// Sets `*iPattern` to one beyond the char that ended the parse, or to
// `spPattern.size()` if no such char occurs. Parsing should resume at
// that position.
WideString GetLiteralText(pdfium::span<const wchar_t> spStrPattern,
                          size_t* iPattern) {}

WideString GetLiteralTextReverse(pdfium::span<const wchar_t> spStrPattern,
                                 size_t* iPattern) {}

bool GetNumericDotIndex(const WideString& wsNum,
                        const WideString& wsDotSymbol,
                        size_t* iDotIndex) {}

bool ExtractCountDigits(pdfium::span<const wchar_t> spStr,
                        size_t count,
                        size_t* cc,
                        uint32_t* value) {}

bool ExtractCountDigitsWithOptional(pdfium::span<const wchar_t> spStr,
                                    int count,
                                    size_t* cc,
                                    uint32_t* value) {}

bool ParseLocaleDate(const WideString& wsDate,
                     const WideString& wsDatePattern,
                     LocaleIface* pLocale,
                     CFX_DateTime* datetime,
                     size_t* cc) {}

void ResolveZone(int tz_diff_minutes,
                 const LocaleIface* pLocale,
                 uint32_t* wHour,
                 uint32_t* wMinute) {}

bool ParseLocaleTime(const WideString& wsTime,
                     const WideString& wsTimePattern,
                     LocaleIface* pLocale,
                     CFX_DateTime* datetime,
                     size_t* cc) {}

size_t GetNumTrailingLimit(const WideString& wsFormat,
                           size_t iDotPos,
                           bool* bTrimTailZeros) {}

bool IsLeapYear(uint32_t year) {}

bool MonthHas30Days(uint32_t month) {}

bool MonthHas31Days(uint32_t month) {}

// |month| is 1-based. e.g. 1 means January.
uint16_t GetSolarMonthDays(uint16_t year, uint16_t month) {}

uint16_t GetWeekDay(uint16_t year, uint16_t month, uint16_t day) {}

uint16_t GetWeekOfMonth(uint16_t year, uint16_t month, uint16_t day) {}

uint16_t GetWeekOfYear(uint16_t year, uint16_t month, uint16_t day) {}

WideString NumToString(size_t fmt_size, int32_t value) {}

WideString DateFormat(const WideString& wsDatePattern,
                      LocaleIface* pLocale,
                      const CFX_DateTime& datetime) {}

WideString TimeFormat(const WideString& wsTimePattern,
                      LocaleIface* pLocale,
                      const CFX_DateTime& datetime) {}

WideString FormatDateTimeInternal(const CFX_DateTime& dt,
                                  const WideString& wsDatePattern,
                                  const WideString& wsTimePattern,
                                  bool bDateFirst,
                                  LocaleIface* pLocale) {}

bool HasDate(CFGAS_StringFormatter::DateTimeType type) {}

bool HasTime(CFGAS_StringFormatter::DateTimeType type) {}

CFGAS_StringFormatter::DateTimeType AddDateToDatelessType(
    CFGAS_StringFormatter::DateTimeType type) {}

CFGAS_StringFormatter::DateTimeType AddTimeToTimelessType(
    CFGAS_StringFormatter::DateTimeType type) {}

}  // namespace

bool FX_DateFromCanonical(pdfium::span<const wchar_t> spDate,
                          CFX_DateTime* datetime) {}

bool FX_TimeFromCanonical(const LocaleIface* pLocale,
                          pdfium::span<const wchar_t> spTime,
                          CFX_DateTime* datetime) {}

CFGAS_StringFormatter::CFGAS_StringFormatter(const WideString& wsPattern)
    :{}

CFGAS_StringFormatter::~CFGAS_StringFormatter() = default;

// static
std::vector<WideString> CFGAS_StringFormatter::SplitOnBars(
    const WideString& wsFormatString) {}

CFGAS_StringFormatter::Category CFGAS_StringFormatter::GetCategory() const {}

WideString CFGAS_StringFormatter::GetTextFormat(
    WideStringView wsCategory) const {}

LocaleIface* CFGAS_StringFormatter::GetNumericFormat(
    LocaleMgrIface* pLocaleMgr,
    size_t* iDotIndex,
    uint32_t* dwStyle,
    WideString* wsPurgePattern) const {}

bool CFGAS_StringFormatter::ParseText(const WideString& wsSrcText,
                                      WideString* wsValue) const {}

bool CFGAS_StringFormatter::ParseNum(LocaleMgrIface* pLocaleMgr,
                                     const WideString& wsSrcNum,
                                     WideString* wsValue) const {}

CFGAS_StringFormatter::DateTimeType CFGAS_StringFormatter::GetDateTimeFormat(
    LocaleMgrIface* pLocaleMgr,
    LocaleIface** pLocale,
    WideString* wsDatePattern,
    WideString* wsTimePattern) const {}

bool CFGAS_StringFormatter::ParseDateTime(LocaleMgrIface* pLocaleMgr,
                                          const WideString& wsSrcDateTime,
                                          DateTimeType eDateTimeType,
                                          CFX_DateTime* dtValue) const {}

bool CFGAS_StringFormatter::ParseZero(const WideString& wsSrcText) const {}

bool CFGAS_StringFormatter::ParseNull(const WideString& wsSrcText) const {}

bool CFGAS_StringFormatter::FormatText(const WideString& wsSrcText,
                                       WideString* wsOutput) const {}

bool CFGAS_StringFormatter::FormatNum(LocaleMgrIface* pLocaleMgr,
                                      const WideString& wsInputNum,
                                      WideString* wsOutput) const {}

bool CFGAS_StringFormatter::FormatDateTime(LocaleMgrIface* pLocaleMgr,
                                           const WideString& wsSrcDateTime,
                                           DateTimeType eDateTimeType,
                                           WideString* wsOutput) const {}

bool CFGAS_StringFormatter::FormatZero(WideString* wsOutput) const {}

bool CFGAS_StringFormatter::FormatNull(WideString* wsOutput) const {}