Duke's Big Numbers 1.0
C++ and Blueprint libraries for performing math, analysis, and formatting with really large numbers (>10e308).
Loading...
Searching...
No Matches
DecimalScalingFormatter.h
1// Copyright (C)2023 Smiling Cat Entertainment, LTD. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "UObject/NoExportTypes.h"
7#include "Internationalization/FastDecimalFormat.h"
8#include "Internationalization/Culture.h"
9
10#include "Inline.h"
11#include "BigIntegerFormatter.h"
12#include "GroupLabeler.h"
13#include "CultureAwareObject.h"
14#include "DecimalScalingFormatter.generated.h"
15
19UCLASS()
20class DUKESBIGNUMBERS_API UDecimalScalingFormatter : public UBigIntegerFormatter, public Duke::MCultureAwareObject
21{
22 GENERATED_BODY()
23
24public:
30
37 static FString ToScientificString(const FBigInteger& number);
38
43 static void AppendScientificToString(const FBigInteger& number, FString& string);
44
51 static FString ToEngineeringString(const FBigInteger& number);
52
57 static void AppendEngineeringToString(const FBigInteger& number, FString& string);
58
65 static FString ToNamedString(const FBigInteger& number);
66
71 static void AppendNamedToString(const FBigInteger& number, FString& string);
72
79 static FString ToSINameString(const FBigInteger& number);
80
85 static void AppendSINameToString(const FBigInteger& number, FString& string);
86
93 static FString ToSISymbolString(const FBigInteger& number);
94
99 static void AppendSISymbolToString(const FBigInteger& number, FString& string);
100
106 static UDecimalScalingFormatter* GetDefaultNamed();
107
113 static UDecimalScalingFormatter* GetDefaultScientific();
114
120 static UDecimalScalingFormatter* GetDefaultEngineering();
121
127 static UDecimalScalingFormatter* GetDefaultSIName();
128
134 static UDecimalScalingFormatter* GetDefaultSISymbol();
135
140 virtual void OnAppendToString(const FBigInteger& number, FString& string) const override;
141
147 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
148 bool GetUseGrouping() const;
149
155 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
156 void SetUseGrouping(bool value);
157
163 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
164 bool GetAlwaysSign() const;
165
171 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
172 void SetAlwaysSign(bool value);
173
179 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
180 int32 GetMinimumPowerAllowed() const;
181
187 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
188 void SetMinimumPowerAllowed(int32 value);
189
195 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
196 int32 GetMaximumPowerAllowed() const;
197
203 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
204 void SetMaximumPowerAllowed(int32 value);
205
211 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
212 int32 GetScaleGranularity() const;
213
219 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
220 void SetScaleGranularity(int32 value);
221
227 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
228 const UGroupLabeler* GetGroupLabeler() const;
229
235 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
236 void SetGroupLabeler(const UGroupLabeler* value);
237
243 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
244 const UBigIntegerFormatter* GetFallbackFormatter() const;
245
251 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
252 void SetFallbackFormatter(const UBigIntegerFormatter* value);
253
255 //* Gets the rounding mode used for the formatting of the number
256 //* @return the rounding mode used for the formatting of the number
257 //* @opcode{I,U1,gornd,SF}
258 //*/
259 //UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
260 //TEnumAsByte<ERoundingMode> const GetRoundingMode() const;
261
263 //* Sets the rounding mode used for the formatting of the number
264 //* @param value the rounding mode used for the formatting of the number
265 //* @opcode{I,0,sornd,SF,U1}
266 //*/
267 //UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
268 //void SetRoundingMode(TEnumAsByte<ERoundingMode> value);
269
275 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
276 int32 GetMinimumFractionalDigits() const;
277
283 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
284 void SetMinimumFractionalDigits(int32 value);
285
291 UFUNCTION(BlueprintPure, BlueprintInternalUseOnly, Category = "String|BigInteger")
292 int32 GetMaximumFractionalDigits() const;
293
299 UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "String|BigInteger")
300 void SetMaximumFractionalDigits(int32 value);
301
302private:
303 static UDecimalScalingFormatter* defaultNamedInstance;
304 static UDecimalScalingFormatter* defaultScientificInstance;
305 static UDecimalScalingFormatter* defaultEngineeringInstance;
306 static UDecimalScalingFormatter* defaultSINameInstance;
307 static UDecimalScalingFormatter* defaultSISymbolInstance;
308
309 static void CreateDefaultNamed();
310 static void CreateDefaultScientific();
311 static void CreateDefaultEngineering();
312 static void CreateDefaultSIName();
313 static void CreateDefaultSISymbol();
314
318 UPROPERTY(BlueprintGetter = GetUseGrouping, BlueprintSetter = SetUseGrouping, Category = "String|BigInteger")
319 bool UseGrouping = true;
320
324 UPROPERTY(BlueprintGetter = GetAlwaysSign, BlueprintSetter = SetAlwaysSign, Category = "String|BigInteger")
325 bool AlwaysSign = false;
326
334 UPROPERTY(BlueprintGetter = GetMinimumPowerAllowed, BlueprintSetter = SetMinimumPowerAllowed, Category = "String|BigInteger")
335 int32 MinimumPowerAllowed;
336
344 UPROPERTY(BlueprintGetter = GetMaximumPowerAllowed, BlueprintSetter = SetMaximumPowerAllowed, Category = "String|BigInteger")
345 int32 MaximumPowerAllowed;
346
352 UPROPERTY(BlueprintGetter = GetScaleGranularity, BlueprintSetter = SetScaleGranularity, Category = "String|BigInteger")
353 int32 ScaleGranularity;
354
359 UPROPERTY(BlueprintGetter = GetGroupLabeler, BlueprintSetter = SetGroupLabeler, Category = "String|BigInteger")
360 const UGroupLabeler* GroupLabeler;
361
363 //* Controls the rounding mode used for the formatting of the number
364 //*/
365 //UPROPERTY(BlueprintGetter = GetRoundingMode, BlueprintSetter = SetRoundingMode, Category = "String|BigInteger")
366 //TEnumAsByte<ERoundingMode> RoundingMode;
367
371 UPROPERTY(BlueprintGetter = GetMinimumFractionalDigits, BlueprintSetter = SetMinimumFractionalDigits, Category = "String|BigInteger")
372 int32 MinimumFractionalDigits;
373
377 UPROPERTY(BlueprintGetter = GetMaximumFractionalDigits, BlueprintSetter = SetMaximumFractionalDigits, Category = "String|BigInteger")
378 int32 MaximumFractionalDigits;
379
384 UPROPERTY(BlueprintGetter = GetFallbackFormatter, BlueprintSetter = SetFallbackFormatter, Category = "String|BigInteger")
385 const UBigIntegerFormatter* FallbackFormatter;
386
387 FDecimalNumberFormattingRules formattingRules;
388 FDecimalNumberFormattingRules internalFormattingRules;
389 FNumberFormattingOptions formattingOptions;
390
391 void BuildOptions();
392 void SetDefaults();
393
394};
395
396// If conditional inlining is ON, include inlinable functions here.
397#if DBN_INLINE_ENABLED
398#include "DecimalScalingFormatter.inl"
399#endif
Definition: BigIntegerFormatter.h:19
Definition: DecimalScalingFormatter.h:21
virtual void OnAppendToString(const FBigInteger &number, FString &string) const override
Definition: GroupLabeler.h:19
Definition: BigInteger.h:50