HLA Standard Library Reference Manual

1 Passing Parameters to Standard Library Routines 1

1.1 Parameter Passing 1

1.2 Passing Parameters by Reference and by Value 2

1.3 Passing Byte Parameters on the Stack 3

1.4 Passing Word Parameters on the Stack 5

1.5 Passing DWord Parameters on the Stack 5

1.6 Passing QWord Parameters on the Stack 6

1.7 Passing TByte Parameters on the Stack 7

1.8 Passing LWord Parameters on the Stack 7

2 Command-Line Arguments (args.hhf) 9

2.1 The Args Module 9

2.2 Retrieving the Command Line 9

2.3 Argument Count and Item 10

2.4 Deleting Command Line Arguments 11

2.5 Argument Iterators 12

3 Arrays Module (arrays.hhf) 15

3.1 The Arrays Module 15

3.2 Array Data Types 15

3.3 Array Allocation and Deallocation 16

3.4 Array Predicates 17

3.5 Array Element Access 17

3.6 Array Operations 18

3.7 Lookup Tables 22

4 Bit Manipulation (bits.hhf) 25

4.1 Bit Module 25

4.2 Bit Counting Function 25

4.3 Bit Reversal Functions 26

4.4 Bit Merging Functions 28

4.5 Bit Extraction Functions 30

4.6 Bit Distribution Functions 32

5 The Blobs Module (blobs.hhf) 35

5.1 Conversion Format Control 35

5.2 Blob Synopsis 35

5.3 Blob Internal Representation 36

5.4 Declaring Blob Variables 36

5.4.1 Initializing and Allocating Blob Variables 37

5.5 Blob Accessor Functions 39

5.6 Blob Assignment Functions 42

5.7 Blob Extraction Functions 44

5.8 Blob Comparison Functions 45

5.9 Blob Scanning Functions 45

5.10 Blob Concatenation Functions 48

5.11 Blob Conversion Functions 51

5.12 General Blob I/O Functions 53

5.13 Blob Binary I/O Routines 55

5.14 Blob Output Routines 63

5.15 Blob Input Routines 64

6 Character Classification and Utilities Module (chars.hhf) 65

6.1 Conversion Functions 65

6.2 Predicates (Tests) 66

7 Console Display Control (console.hhf) 73

7.1 The Console Module Module 73

7.2 Cursor Positioning Functions 73

7.3 Console Clearing Functions 76

7.4 Character Insertion/Removal Functions 78

7.5 Console Scrolling 80

7.6 Console Output Colors 81

8 Conversions (conv.hhf) 83

8.1 Buffer vs. String Conversions 83

8.2 Conversion Format Control 84

8.2.1 Underscore Control 84

8.2.2 Delimiter Control 87

8.3 Hexadecimal Conversions 91

8.3.1 Internal Routines 92

8.3.2 Hexadecimal Numeric Size Functions 92

8.3.2.1 Fixed Size Hexadecimal Size Functions 92

8.3.2.2 Standard Hexadecimal Size Functions 96

8.3.3 Hexadecimal Numeric to Buffer Conversions 101

8.3.3.1 Fixed Length Hexadecimal Numeric to Buffer Conversions 101

8.3.3.2 Variable Length Hexadecimal Numeric to Buffer Conversions 108

8.3.4 Hexadecimal Numeric to String Conversions 115

8.3.4.1 Fixed-Length Numeric to Hexadecimal String Conversions 115

8.3.4.2 Variable-Length Numeric to Hexadecimal String Conversions 130

8.3.5 Hexadecimal Buffer to Numeric Conversions 146

8.3.6 Hexadecimal String to Numeric Conversions 151

8.4 Signed Integer Conversions 157

8.4.1 Internal Functions 157

8.4.2 Integer Size Calculations 157

8.4.3 Signed Integer Numeric to Buffer Conversions 161

8.4.4 Integer Numeric to String Conversions 167

8.4.5 Signed Integer String to Numeric Conversions 182

8.5 Unsigned Integer Conversions 192

8.5.1 Internal Routines 193

8.5.2 Unsigned Integer Size Calculations 193

8.5.3 Unsigned Integer Numeric to Buffer Conversions 197

8.5.4 Unsigned Integer Numeric to String Conversions 203

8.5.5 Unsigned Integer String to Numeric Conversions 219

8.6 Floating Point Conversions 229

8.6.1 Exponential Floating-Point Conversions 229

8.6.2 Floating Point Numeric to Buffer Conversions, Exponential Form 230

8.6.3 Floating Point Numeric to String Conversions, Exponential Form 232

8.6.4 Floating Point Numeric to Character Conversions, Decimal Form 236

8.6.5 Floating-Point Numeric to String Conversions, Decimal Form 240

8.6.6 Floating Point String/Buffer to Numeric Conversions 244

8.6.7 Roman Numeral Conversion 245

9 Coroutines Module (coroutines.hhf) 247

9.1 The Coroutine Module 247

9.2 The Coroutine Class Definition 247

9.3 Coroutine Functions 248

10 Character Sets (cset.hhf) 251

10.1 Predicates (tests) 251

10.2 Character Set Construction and Manipulation 259

10.3 Set Operations 267

11 Date Functions (datetime.hhf) 279

11.1 The Date Module 279

11.2 Date Data Types 279

11.3 Date Tables 280

11.4 Date Predicates 281

11.5 Date Conversions 283

11.6 Date Arithmetic 286

11.7 Reading the Current System Date 289

11.8 Date Output and String Conversion 290

11.9 Date Class Types 291

11.9.1 Date Class Methods/Procedures 292

11.9.2 Creating New Date Class Types 293

11.9.3 Date Class Functions 297

12 Environment Variables Module (env.hhf) 301

12.1 The Env Module 301

12.2 Retrieving Environment Strings 301

13 Exceptions Module (excepts.hhf) 303

13.1 The Exceptions Module 303

13.2 Exception Resource Reduction 303

13.3 Exception Constants 303

13.4 Exception Messages 310

14 File Class Module (fileclass.hhf) 313

14.1 File Class Methods/Procedures 313

14.2 A Quick Note 314

14.3 General File Operations 314

14.4 Opening and Closing Files 315

14.5 File Predicates 316

14.6 Miscellaneous Output 317

14.7 Character, Character Set, and String Output 318

14.8 Hexadecimal Numeric Output 319

14.9 Signed Integer Numeric Output 323

14.10 Unsigned Integer Numeric Output 326

14.11 Floating-Point Numeric Output Using Scientific Notation 329

14.12 Floating-Point Numeric Output Using Decimal Notation 330

14.13 Generic File Output 332

14.14 Generic File Input 333

14.15 Character and String Input 333

14.16 Signed Integer Input 334

14.17 Unsigned Integer Input 336

14.18 Hexadecimal Input 337

14.19 Floating-Point Input 339

14.20 Generic File Input 339

15 The File I/O Module (fileio.hhf) 341

15.1 Conversion Format Control 341

15.2 General File I/O Functions 341

15.3 File Output Routines 354

15.3.1 Miscellaneous Output Routines 354

15.3.2 Character, String, and Character Set Output Routines 358

15.3.3 Hexadecimal Output Routines 365

15.3.4 Signed Integer Output Routines 388

15.3.5 Unsigned Integer Output Routines 402

15.3.6 Floating Point Output Routines 416

15.3.6.1 Real Output Using Scientific Notation 416

15.3.6.2 Real Output Using Decimal Notation 420

15.3.7 Generic File Output Routine 424

15.4 File Input Routines 425

15.4.1 General File Input Routines 425

15.4.2 Character and String Input Routines 428

15.4.3 Signed Integer Input Routines 430

15.4.4 Unsigned Integer Input Routines 434

15.4.5 Hexadecimal Input Routines 437

15.4.6 Floating Point Input 442

15.4.7 Generic File Input 443

16 The File System Module (filesys.hhf) 445

16.1 Filename and Pathname String Functions 445

16.2 Directory and File Predicates 461

16.3 File Information Functions 462

16.4 Directory and File Manipulation Functions 463

17 HLA Related Macros and Constants (hla.hhf) 469

17.1 The HLA Module 469

17.2 Classification Macros 469

17.3 String to Integer Macros 470

17.4 Label Generation Macro 470

17.5 Procedure Overloading Macro 470

17.6 Generic PUT Macro 473

17.7 @class Constants 478

17.8 HLA pType Constants 479

17.9 @pclass Return Values 481

17.10 @section Return Values 482

18 The Linux Module (linux.hhf) 485

18.1 The Linux Module 485

18.2 The Linux Header File 485

19 Lists Module (lists.hhf) 487

19.1 The Lists Module 487

19.1.0.1 List Data Types 487

19.2 List_t Class Function Types 489

19.3 Creating New List Class Types 490

19.4 List Procedures, Methods, and Iterators 491

19.5 List Constructor and Destructor 492

19.6 Accessor Functions 493

19.6.0.1 Adding Nodes to a List 493

19.7 Removing Nodes From a List 495

19.8 Accessing Nodes in a List 497

19.9 Miscellaneous List Functions 499

20 Math Module (math.hhf) 503

20.1 The Math Module 503

20.2 Math Data Types 503

20.3 64-Bit Arithmetic and Logical Operations 503

20.4 128-Bit Arithmetic and Logical Operations 511

20.5 Transcendental, Logarithmic, and Other Floating-Point Operations 520

21 Memory-Mapped I/O (mmap.hhf) 547

21.1 MMAP Module 547

21.2 Class Fields 547

21.3 Class Procedures and Methods 547

22 Memory (memory.hhf) 551

22.1 Memory Module 551

22.2 Deprecated Names 551

22.3 Generic Memory Allocation 551

22.4 String Memory Allocation 558

23 OS Module (os.hhf) 561

23.1 The OS Module 561

23.2 Executing Shell Commands 561

23.3 Delaying Program Execution 562

24 Patterns Module (patterns.hhf) 563

24.1 The Patterns Module 563

24.2 An Introduction to Pattern Matching (a tutorial) 563

24.3 Pattern Matching Functions Versus User Code 567

24.4 Register and Stack Usage in Pattern Matching Statements 568

24.5 Nesting Pattern Matching Statements 570

24.6 Cleanly Nesting Patterns 574

24.7 Backtracking 576

24.8 Pattern Components 578

24.9 Lazy / Eager Evaluation and Pattern Matching Performance 579

24.10 Regular Expressions 580

24.11 Pattern Matching Statements 585

24.12 Alternation 586

24.13 Pattern Matching Macros 587

24.14 Character Set Matching Functions 590

24.15 Character Matching Functions 595

24.16 Case Insensitive Character Matching Routines 600

24.17 String Extraction Functions 606

24.18 Whitespace and End of String Matching Functions 607

24.19 Matching an Arbitrary Sequence of Characters 608

24.20 Writing Your Own Pattern Matching Routines 609

25 Random Number Generator Module (rand.hhf) 621

25.1 The Random Module 621

25.2 The Random Number Generators 621

26 Sockets Module (sockets.hhf) 625

26.1 The SOCK Module 625

26.2 Socket Initialization and Cleanup 625

26.3 Generic Socket Functions 625

26.4 Low-Level BSD-Style Socket Functions 626

26.5 Socket Classes 634

26.6 A Quick Note 635

26.7 Client/Server Applications Using the Socket Classes 635

26.8 A Simple Server Application 635

26.9 A Simple Client Application 638

26.10 Client/Server Communication 638

26.11 General Socket Class Operations 639

26.12 Miscellaneous Output 642

26.13 Character, Character Set, and String Output 643

26.14 Hexadecimal Numeric Output 645

26.15 Signed Integer Numeric Output 649

26.16 Unsigned Integer Numeric Output 652

26.17 Floating-Point Numeric Output Using Scientific Notation 654

26.18 Floating-Point Numeric Output Using Decimal Notation 656

26.19 Generic File Output 657

26.20 Generic File Input 658

26.21 Character and String Input 659

26.22 Signed Integer Input 660

26.23 Unsigned Integer Input 661

26.24 Hexadecimal Input 663

26.25 Floating-Point Input 664

26.26 Generic File Input 665

27 The Standard Error Module (stderr.hhf) 667

27.1 Conversion Format Control 667

27.2 File I/O Routines and the Standard Error Handle 667

27.3 Standard Error Routines 667

27.4 Miscellaneous Output Routines 668

27.5 Boolean Output 669

27.6 Character, String, and Character Set Output Routines 670

27.7 Hexadecimal Output Routines 676

27.8 Signed Integer Output Routines 698

27.9 Unsigned Integer Output Routines 711

27.10 Floating Point Output Routines 725

27.10.1 Real Output Using Scientific Notation 725

27.10.2 Real Output Using Decimal Notation 728

27.11 Generic Error Output Routine 733

28 The Standard Input Module (stdin.hhf) 735

28.1 Conversion Format Control 735

28.2 File I/O Routines and the Standard Output Handle 735

28.3 Standard Input Routines 735

28.4 General Standard Input Routines 736

28.5 Character and String Input Routines 738

28.6 Hexadecimal Input Routines 739

28.7 Signed Integer Input Routines 742

28.8 Unsigned Integer Input Routines 744

28.9 Floating Point Input 747

28.10 Generic File Input 747

29 The Standard Output Module (stdout.hhf) 749

29.1 Conversion Format Control 749

29.2 File I/O Routines and the Standard Output Handle 749

29.3 Standard Output Routines 749

29.4 Miscellaneous Output Routines 750

29.5 Boolean Output 751

29.6 Character, String, and Character Set Output Routines 752

29.7 Hexadecimal Output Routines 759

29.8 Signed Integer Output Routines 781

29.9 Unsigned Integer Output Routines 794

29.10 Floating Point Output Routines 807

29.10.1 Real Output Using Scientific Notation 807

29.10.2 Real Output Using Decimal Notation 810

29.11 Generic Standard Output Routine 815

30 The HLA Standard Template Library 817

30.1 Introduction to the HLA STL 817

30.2 Type Declarations Created by a Template 818

30.3 Template Objects are Classes 818

30.4 Class Traits 819

30.4.1 isSTL_c Trait 819

30.4.2 Compile-Time Traits 820

30.4.3 Run-Time Traits 820

30.4.4 Trait Constants 821

30.4.4.1 stl.isContainer_c Trait 821

30.4.4.2 stl.isRandomAccess_c Trait 822

30.4.4.3 stl.isArray_c Trait 822

30.4.4.4 stl.isVector_c Trait 822

30.4.4.5 stl.isDeque_c Trait 822

30.4.4.6 stl.isList_c Trait 822

30.4.4.7 stl.isTable_c Trait 822

30.4.4.8 stl.supportsOutput_c Trait 822

30.4.4.9 stl.supportsCompare_c Trait 822

30.4.4.10 stl.supportsInsert_c Trait 822

30.4.4.11 stl.supportsRemove_c Trait 822

30.4.4.12 stl.supportsAppend_c Trait 822

30.4.4.13 stl.supportsPrepend_c Trait 822

30.4.4.14 stl.supportsForEach_c and supportsrForeach_c Traits 823

30.4.4.15 stl.supportsCursor_c Trait 823

30.4.4.16 stl.supportsSearch_c Trait 823

30.4.4.17 stl.supportsElementSwap_c Trait 823

30.4.4.18 stl.supportsObjSwap_c Trait 823

30.4.4.19 stl.elementsAreObjects_c Trait 823

30.4.4.20 stl.fastInsert_c Trait 823

30.4.4.21 stl.fastRemove_c Trait 823

30.4.4.22 stl.fastAppend_c Trait 823

30.4.4.23 stl.fastPrepend_c Trait 823

30.4.4.24 stl.fastSwap_c Trait 824

30.4.4.25 stl.fastSearch_c Trait 824

30.4.4.26 stl.fastElementSwap_c Trait 824

30.4.5 Other Run-Time Traits 824

30.5 The Vector Template 824

30.6 The Deque Template 824

30.7 The List Template 824

30.8 The Table Template 824

31 The Strings Module (strings.hhf) 825

31.1 The HLA String Data Type 825

31.2 String Allocation Macros and Functions 827

31.3 String Length Calculations 828

31.4 String Assignment 828

31.5 Substring Functions 830

31.6 String Insertion and Deletion Functions 836

31.7 String Comparison Functions 844

31.8 String Searching Functions 850

31.9 Character Set Searching Functions 863

31.10 String Parsing Functions 869

31.11 String Formatting Functions 885

31.12 String Conversion Functions 897

31.13 String Concatentation Functions 904

31.14 String Value Concatentation Functions 911

31.14.1 Boolean Output 911

31.14.2 Character, String, and Character Set Concatenation Routines 912

31.14.3 Hexadecimal Concatenation Routines 917

31.14.4 Signed Integer Concatenation Routines 932

31.14.5 Unsigned Integer Concatenation Routines 942

31.15 Floating-Point Concatenation Routines 952

31.15.1 Real to String Output Using Scientific Notation 953

31.15.2 Real To String Output Using Decimal Notation 955

31.16 Generic String Format Output Routine 959

32 High-Level Language Module (hll.hhf) 961

32.1 The HLL Module 961

32.2 The switch/case/default/endswitch Macro 961

33 Tables Module (tables.hhf) 963

33.1 The Tables Module 963

33.2 The Table Class 963

34 Threads Module (threads.hhf) 967

34.1 Threads Module 967

34.2 Thread Creation 967

34.3 Thread Identification 968

34.4 Thread Local Storage 969

34.5 Events 971

34.6 Critical Sections 972

34.7 Semaphores 974

35 Time Functions (datetime.hhf) 977

35.1 Time Module 977

35.2 Time Data Types 977

35.3 Time Predicates 978

35.4 Time Conversions 980

35.5 Time Arithmetic 983

35.6 Reading the Current System Time 986

35.7 Time String Conversions and Output 987

35.8 Time Class Types 988

35.9 Time Class Methods/Procedures 988

35.10 Creating New Time Class Types 989

35.11 Time Class Functions 993

36 Timer Class and Module (timer.hhf) 997

36.1 Timer Module 997

36.2 Timer Class/Data Structure 997

36.3 Timer Operation 998

36.4 Timer Class Fields 998

36.5 Timer Procedures and Methods 998

37 Zero-terminated String Functions (zstring.hhf) 1001

37.1 ZStrings Module 1002

37.2 Zstring Functions 1002