unihtml/sizes/sizes.go
2021-02-08 19:36:06 +00:00

174 lines
13 KiB
Go

//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
// Package sizes defines basic types that determines the size units i.e. lengths.
//
//
package sizes ;import (_c "encoding/json";_d "flag";_ee "fmt";_fb "github.com/pkg/errors";_e "strconv";_a "strings";);
// Type implements pflag.Value interface.
func (_fab PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"};
// UnmarshalPageSize unmarshals the page size from the string.
func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _cb PageSize ;if _ecf :=(&_cb ).UnmarshalText ([]byte (pageSize ));_ecf !=nil {return 0,_fb .Wrap (_ecf ,"\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065\u0020s\u0069\u007a\u0065");};return _cb ,nil ;};
// PageSizeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func PageSizeString (s string )(PageSize ,error ){if _dcb ,_aafe :=_bd [s ];_aafe {return _dcb ,nil ;};return 0,_ee .Errorf ("\u0025\u0073 \u0064\u006f\u0065\u0073 \u006e\u006ft\u0020\u0062\u0065\u006c\u006f\u006e\u0067\u0020t\u006f\u0020\u0050\u0061\u0067\u0065\u0053\u0069\u007a\u0065\u0020\u0076a\u006c\u0075\u0065\u0073",s );};const (Portrait =Orientation (false );Landscape =Orientation (true ););
// Set implements flag.Value interface.
func (_fde *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_fde =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_fde =Landscape ;default:return _ee .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s );};return nil ;};
// Inch is a unit that
type Inch float64 ;
// Type implements pflag.Value interface.
func (_ae *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"};func _bce (_ga string )(Inch ,error ){_ga =_a .TrimSpace (_a .Trim (_ga ,"\u0069\u006e"));_ddg ,_be :=_e .ParseFloat (_ga ,64);if _be !=nil {return 0,_fb .Wrap (_be ,"\u0069n\u0076a\u006c\u0069\u0064\u0020\u0069n\u0063\u0068 \u0076\u0061\u006c\u0075\u0065");};return Inch (_ddg ),nil ;};var _ Length =Inch (0);
// Set implements flag.Value interface.
func (_gbb *Point )Set (s string )error {_ad ,_aa :=_e .ParseFloat (s ,64);if _aa !=nil {return _fb .Wrap (_aa ,"\u0069n\u0076a\u006c\u0069\u0064\u0020\u0069n\u0063\u0068 \u0076\u0061\u006c\u0075\u0065");};*_gbb =Point (_ad );return nil ;};
// String implements fmt.Stringer interface.
func (_dec Point )String ()string {_af :=_a .Builder {};_af .WriteString (_e .FormatFloat (float64 (_dec ),'f',1,64));_af .WriteString ("\u0070\u0074");return _af .String ();};var _ _d .Value =(*Orientation )(nil );
// Inches gets the inch value. Implements Length interface.
func (_fc Inch )Inches ()Inch {return _fc };
// Point is a unit of Length commonly used to measure the height of fonts.
type Point float64 ;
// Millimeter is the dimension unit that defines a millimeter.
type Millimeter float64 ;
// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise
func (_gbe PageSize )IsAPageSize ()bool {for _ ,_gc :=range _eeb {if _gbe ==_gc {return true ;};};return false ;};
// MarshalUnit marshals the unit into the string.
func MarshalUnit (unit Length )(string ,error ){switch _aaf :=unit .(type ){case Millimeter :return _ee .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_aaf ),nil ;case Inch :return _ee .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_aaf ),nil ;case Point :return _ee .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_aaf ),nil ;default:return "",_ee .Errorf ("i\u006e\u0076\u0061\u006cid\u0020u\u006e\u0069\u0074\u0020\u0074y\u0070\u0065\u003a\u0020\u0025\u0054",unit );};};
// Set implements pflag.Value interface.
func (_dfb *PageSize )Set (s string )error {_cad ,_bcg :=UnmarshalPageSize (s );if _bcg !=nil {return _bcg ;};*_dfb =_cad ;return nil ;};
// Points implements Length interface.
func (_ebf Millimeter )Points ()Point {return Point (_ebf *_db )};
// Name implements viper.FlagValue interface.
func (_dc Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};
// UnmarshalLength unmarshalls string value into Length.
func UnmarshalLength (length string )(Length ,error ){if _a .HasSuffix (length ,"\u006d\u006d"){return _faf (length );};if _a .HasSuffix (length ,"\u0069\u006e"){return _bce (length );};if _a .HasSuffix (length ,"\u0070\u0074"){return _ggb (length );};return nil ,_ee .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020\u0025\u0073",length );};func _ggb (_afg string )(Point ,error ){_afg =_a .TrimSpace (_a .Trim (_afg ,"\u0070\u0074"));_bb ,_cf :=_e .ParseFloat (_afg ,64);if _cf !=nil {return 0,_cf ;};return Point (_bb ),nil ;};
// Dimensions gets the dimensions of the given page size.
// If provided page size is not valid than the function returns 0 values.
func (_gf PageSize )Dimensions ()(_eaa ,_dbad Millimeter ){switch _gf {case A0 :return 841,1189;case A1 :return 594,841;case A2 :return 420,594;case A3 :return 297,420;case A4 :return 210,297;case A5 :return 148,210;case A6 :return 105,148;case A7 :return 74,105;case A8 :return 52,74;case A9 :return 37,52;case A10 :return 26,37;case B0 :return 1000,1414;case B1 :return 707,1000;case B2 :return 500,707;case B3 :return 353,500;case B4 :return 250,353;case B5 :return 176,250;case B6 :return 125,176;case B7 :return 88,125;case B8 :return 66,88;case B9 :return 44,62;case B10 :return 31,44;case Letter :return 215.9,279.4;};return _eaa ,_dbad ;};
// String gets the string value for given flag.
func (_fa *LengthFlag )String ()string {if _fa .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _fa .Length .String ();};
// Type implements pflag.Value interface.
func (_aee Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};var _ce =[...]uint8 {0,9,11,13,15,17,19,21,23,25,27,29,32,34,36,38,40,42,44,46,48,50,52,55,61};
// Inches gets the inches equivalent from provided millimeter value.
func (_ccf Millimeter )Inches ()Inch {return Inch (float64 (_ccf )*_de )};
// Millimeters converts the inches value to the millimeters.
func (_ggc Point )Millimeters ()Millimeter {return Millimeter (float64 (_ggc )*_da )};
// ValueString implements pflag.Value interface.
func (_dba Inch )ValueString ()string {return _dba .String ()};
// HasChanged implements pflag.Value interface.
func (_ca *Inch )HasChanged ()bool {return _ca !=nil };const (_de =float64 (1)/float64 (25.4);_g =25.4;_gd =0.0139;_da =0.3528;_eb =1/64;_db =1/_da ;);
// Type implements pflag.Value interface.
func (_bc Inch )Type ()string {return "\u0069\u006e\u0063\u0068"};var _bd =map[string ]PageSize {_dbe [0:9]:0,_dbe [9:11]:1,_dbe [11:13]:2,_dbe [13:15]:3,_dbe [15:17]:4,_dbe [17:19]:5,_dbe [19:21]:6,_dbe [21:23]:7,_dbe [23:25]:8,_dbe [25:27]:9,_dbe [27:29]:10,_dbe [29:32]:11,_dbe [32:34]:12,_dbe [34:36]:13,_dbe [36:38]:14,_dbe [38:40]:15,_dbe [40:42]:16,_dbe [42:44]:17,_dbe [44:46]:18,_dbe [46:48]:19,_dbe [48:50]:20,_dbe [50:52]:21,_dbe [52:55]:22,_dbe [55:61]:23};const (Undefined PageSize =iota ;A0 ;A1 ;A2 ;A3 ;A4 ;A5 ;A6 ;A7 ;A8 ;A9 ;A10 ;B0 ;B1 ;B2 ;B3 ;B4 ;B5 ;B6 ;B7 ;B8 ;B9 ;B10 ;Letter ;);
// String implements fmt.Stringer interface.
func (_fd Millimeter )String ()string {_fe :=_a .Builder {};_fe .WriteString (_e .FormatFloat (float64 (_fd ),'f',1,64));_fe .WriteString ("\u006d\u006d");return _fe .String ();};
// Points implements Length interface.
func (_gdc Point )Points ()Point {return _gdc };
// ValueType implements viper.FlagValue interface.
func (_ec Point )ValueType ()string {return _ec .Type ()};
// UnmarshalInch unmarshalls provided string into unit.
func UnmarshalInch (unit string )(Inch ,error ){if _a .HasSuffix (unit ,"\u006d\u006d"){_aed ,_aec :=_faf (unit );if _aec !=nil {return 0,_aec ;};return _aed .Inches (),nil ;};if _a .HasSuffix (unit ,"\u0069\u006e"){return _bce (unit );};return 0,_ee .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit );};const _dbe ="U\u006e\u0064\u0065\u0066\u0069\u006e\u0065\u0064\u0041\u0030\u0041\u0031\u0041\u0032\u0041\u0033\u0041\u0034\u0041\u0035\u0041\u0036\u0041\u0037\u0041\u0038A\u0039A\u0031\u0030\u0042\u0030B\u0031\u00422\u0042\u0033\u0042\u0034\u0042\u0035\u0042\u0036\u0042\u0037\u0042\u0038\u0042\u0039\u0042\u0031\u0030\u004c\u0065\u0074\u0074\u0065\u0072";
// MarshalText implements the encoding.TextMarshaler interface for PageSize
func (_fcf PageSize )MarshalText ()([]byte ,error ){return []byte (_fcf .String ()),nil };
// Set sets the unit value.
// Implements pflag.Value interface.
func (_b *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_b .Length =nil ;return nil ;};_gb ,_cc :=UnmarshalLength (s );if _cc !=nil {return _cc ;};_b .Length =_gb ;return nil ;};
// String implements fmt.Stringer interface.
func (_cg Orientation )String ()string {if _cg ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";};
// MarshalPageSize marshals the page size into string.
func MarshalPageSize (p PageSize )(string ,error ){_adg ,_ece :=p .MarshalText ();if _ece !=nil {return "",_ece ;};return string (_adg ),nil ;};
// PageSize is the enum used for defining the page size.
type PageSize int ;
// Inches gets the inch value. Implements Length interface.
func (_bg Point )Inches ()Inch {return Inch (float64 (_bg )*_gd )};
// Orientation is the page orientation type wrapper.
type Orientation bool ;
// Points implements Length interface.
func (_bfeg Inch )Points ()Point {return Point (float64 (_bfeg )*_eb )};
// Name implements pflag.Value interface.
func (_bcc Inch )Name ()string {return "\u0069\u006e\u0063\u0068"};
// HasChanged implements viper.FlagValue interface.
func (_ef *Point )HasChanged ()bool {return _ef !=nil };
// ValueType implements pflag.Value interface.
func (_ge Inch )ValueType ()string {return _ge .Type ()};
// ValueString implements viper.FlagValue interface.
func (_adf Point )ValueString ()string {return _adf .String ()};
// MarshalJSON implements the json.Marshaler interface for PageSize
func (_fbe PageSize )MarshalJSON ()([]byte ,error ){return _c .Marshal (_fbe .String ())};var (_ Length =Millimeter (0););
// String implements fmt.Stringer interface.
func (_bf Inch )String ()string {_ebb :=_a .Builder {};_ebb .WriteString (_e .FormatFloat (float64 (_bf ),'f',1,64));_ebb .WriteString ("\u0069\u006e");return _ebb .String ();};func _faf (_dcf string )(Millimeter ,error ){_dcf =_a .TrimSpace (_a .TrimSuffix (_dcf ,"\u006d\u006d"));_gea ,_ed :=_e .ParseFloat (_dcf ,64);if _ed !=nil {return 0,_fb .Wrap (_ed ,"\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006d\u0069\u006c\u006c\u0069m\u0065\u0074\u0065\u0072\u0020\u0076\u0061\u006c\u0075\u0065");};return Millimeter (_gea ),nil ;};
// Millimeters converts the inches value to the millimeters.
func (_bfe Inch )Millimeters ()Millimeter {return Millimeter (float64 (_bfe )*_g )};
// Set implements pflag.Value interface.
func (_dd *Inch )Set (s string )error {_ab ,_daf :=_e .ParseFloat (s ,64);if _daf !=nil {return _fb .Wrap (_daf ,"\u0069n\u0076a\u006c\u0069\u0064\u0020\u0069n\u0063\u0068 \u0076\u0061\u006c\u0075\u0065");};*_dd =Inch (_ab );return nil ;};
// Length is it the default dimension unit.
type Length interface{Millimeters ()Millimeter ;Inches ()Inch ;Points ()Point ;String ()string ;};
// UnmarshalJSON implements the json.Unmarshaler interface for PageSize
func (_abb *PageSize )UnmarshalJSON (data []byte )error {var _ddb string ;if _ag :=_c .Unmarshal (data ,&_ddb );_ag !=nil {return _ee .Errorf ("P\u0061\u0067\u0065\u0053\u0069\u007ae\u0020\u0073\u0068\u006f\u0075\u006cd\u0020\u0062\u0065\u0020\u0061\u0020\u0073t\u0072\u0069\u006e\u0067\u002c\u0020\u0067\u006f\u0074\u0020%\u0073",data );};var _aba error ;*_abb ,_aba =PageSizeString (_ddb );return _aba ;};
// PageSizeValues returns all values of the enum
func PageSizeValues ()[]PageSize {return _eeb };
// Type implements pflag.Value interface.
func (_gg Point )Type ()string {return "\u0070\u006f\u0069n\u0074"};var _ _d .Value =(*Point )(nil );
// LengthFlag is a pflag wrapper for the Length value.
type LengthFlag struct{Length Length ;};var _eeb =[]PageSize {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
// UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize
func (_bef *PageSize )UnmarshalText (text []byte )error {var _ded error ;*_bef ,_ded =PageSizeString (string (text ));return _ded ;};func (_edc PageSize )String ()string {if _edc < 0||_edc >=PageSize (len (_ce )-1){return _ee .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_edc );};return _dbe [_ce [_edc ]:_ce [_edc +1]];};
// Millimeters gets the float64 millimeter value.
func (_ea Millimeter )Millimeters ()Millimeter {return _ea };