std Module
Note:
The STD module cannot be directly imported through the import std command. Otherwise, an error indicating that the STD package cannot be found is reported during compilation. (error: can not find package 'std'). You are advised to import the std subpackage to use the std module.
Function Description
The std module refers to a standard library. In programming languages, a standard library is a group of predefined functions, classes, and structs. It is intended to provide commonly used functionality and tools so that developers can compile programs more quickly and efficiently.
Capabilities provided by the Cangjie standard library include but are not limited to the following:
- I/O: console I/O and file I/O;
- data structures: arrays, linked lists, and hash tables;
- algorithms: sorting, summation, exponentiation, and logarithm;
- date and time: obtaining time, formatting time, and setting scheduled tasks; and
- concurrent programming: locks, atomic operations, and the like.
The Cangjie standard library has three features:
- Ease of use: The standard library is released with the compiler and tool chain. You do not need to download them separately.
- Function universality: The standard library provides some commonly-used library capabilities so that you can solve most basic problems.
- Quality benchmark: The standard library aims to set examples and benchmarks for other Cangjie libraries in terms of performance and code style.
Packages of the std Module
The std module provides the following packages:
Name | Description |
---|---|
core | Specifies the core package of the standard library and provides fundamental APIs for Cangjie programming. |
argopt | Provides capabilities for parsing parameter names and values from command line parameter strings. |
ast | Contains the syntax parser of Cangjie source code and Cangjie syntax tree nodes, and provides syntactic parsing functions. |
binary | Provides interfaces for converting and reversing the endianness of basic data types and binary byte arrays. |
collection | Provides efficient implementations of commonly used data structures, definitions of related abstract interfaces, and functions in the collection type. |
collection.concurrent | Provides implementations of the concurrent collection type. |
console | Provides methods for interaction with standard input, standard output, and standard errors. |
convert | Provides a series of Convert functions for converting strings into specific types. |
crypto.cipher | Provides common APIs for symmetric encryption and decryption. |
crypto.digest | Provides common interfaces for digest algorithms, including MD5, SHA1, SHA224, SHA256, SHA384, SHA512, HMAC, and SM3. |
database.sql | Provides interfaces for access to Cangjie databases. |
ffi.python | Provides the interoperability between Cangjie and Python for compatibility with powerful computing and AI ecosystems. |
format | Provides the formatting capability for converting Cangjie instances into formatted strings. |
fs | Provides functions for operations with files, folders, paths, and file metadata. |
io | Allows the program to exchange data with external devices. |
log | Provides functionality of log management and printing. |
math | Provides functionality including commonly used mathematical operations, constant definition, and floating-point number processing. |
math.numeric | Extends the expressible range of basic types. |
objectpool | Provides functionality of object caching and reuse. |
os | Provides capabilities of obtaining information related to current process of the OR operation (such as process parameters, environment variables, and directory information), registering callback functions, and exiting the current process. |
os.posix | Adapts to POSIX interfaces. |
os.process | Provides Process operation interfaces, including process creation, standard flow obtaining, process waiting, and process information querying. |
overflow | Provides overflow processing capabilities. |
random | Provides the capability of generating pseudo-random numbers. |
reflect | Provides the reflection function, enabling a running program to obtain the type information of instances and execute read, write, and call operations. |
regex | Provides the capability of analyzing and processing text (ASCII character strings only) through regular expressions, and supports functions such as search, segmentation, replacement, and verification. |
runtime | Interacts with the runtime environment of a program. It provides a series of functions and variables for controlling, managing, and monitoring the execution of the program. |
socket | Provides functionality such as starting a Socket server, connecting to a Socket server, sending data, and receiving data, and is used for network communication. |
sort | Provides sorting functions of the array type. |
sync | Provides concurrent programming capabilities. |
time | Provides time-related types, including date and time, time interval, monotonic time, and time zone, and provides functionality of calculation and comparison. |
unicode | Provides the capability of processing characters according to the unicode encoding standard. |
unittest | Compiles the unit test code of Cangjie projects and provides basic functionality such as code compilation, running, and debugging. |
unittest.mock | Provides a mock framework for Cangjie unit tests and provides APIs for creating and configuring mock objects. These mock objects and the real objects have the same APIs. |
unittest.testmacro | Provides macros for the unit test framework. |
unittest.mock.mockmacro | Provides macros for the mock framework. |
unittest.common | Provides the unit test framework with the types and common methods required by printing. |
unittest.diff | Provides the unit test framework with APIs for printing difference comparison information. |
unittest.prop_test | Provides the unit test framework with the types and common methods required by parameterized tests. |