(SOC) Storage Only Commit
(ADD) Name, NameScope, Catlog, Object, String, Attribute, Char, Registry, Utils, Type, <Platform Support>, <Global Constants>, README (MOD) Array, Var, Status, MemMan, <Common>
This commit is contained in:
88
name.h
Normal file
88
name.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef COMPOUND_NAME_H
|
||||
# define COMPOUND_NAME_H
|
||||
|
||||
# include <Compound/common.h>
|
||||
# include <Compound/status.h>
|
||||
# include <Compound/array.h>
|
||||
|
||||
// Name, is a base of numeral counting.
|
||||
// It uses 63 as the base, lasts for 63 times.
|
||||
// At the head of each Name, 8 pilots stores for its type.
|
||||
// In total, ((26*2+10+1)^63)*8
|
||||
// = 63^63*8
|
||||
// = 1.82618429078e+114
|
||||
// Nice. :3
|
||||
// William, Sun 12 May, 2024, 02:29:36
|
||||
|
||||
# define NAME_LENGTH_MAXIMUM 64
|
||||
# define NAME_LEGAL_CHARACTERS "abcdefghijklmnopqrstuvwxyz"\
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"\
|
||||
"1234567890"
|
||||
|
||||
typedef struct {
|
||||
char *identifier;
|
||||
Array(int) attributions;
|
||||
} Name;
|
||||
|
||||
static const Name NullName = {
|
||||
.identifier =
|
||||
"_000000000000000000000000000000000000000000000000000000000000000",
|
||||
.attributions = NULL
|
||||
};
|
||||
|
||||
// typedef struct {
|
||||
// Name value;
|
||||
// Name idx;
|
||||
// Name *occupied;
|
||||
// } NameSpace; // Size: 8+8+8 =8*3 =24 Bytes (x64)
|
||||
|
||||
/*
|
||||
* Example:
|
||||
* Var variable_from_namespace_Utils_in_class_Calculation_in_function_C;
|
||||
* // Not enough room for representation.
|
||||
* // Must use another more efficient method to store the name.
|
||||
* Become (roughly):
|
||||
* Var v0000000000000000000000000000000000000000000000000000000000001g3;
|
||||
* Var v1g3; // Trimmed.
|
||||
* PILOT: v, f, c, e, i, s, u, a
|
||||
* v: Variable
|
||||
* f: Function
|
||||
* c: Class
|
||||
* e: Enumeration
|
||||
* i: Interface
|
||||
* s: Struct
|
||||
* u: Union
|
||||
* a: Attribution
|
||||
* ID: [a-zA-Z0-9_]
|
||||
* MAXIMUM STORING SIZE: 63 Bytes
|
||||
* TOTAL POSSIBILITIES: ((26*2+10+1)^63)*8 = 1.82618429078e+114
|
||||
* Definitely enough.
|
||||
*
|
||||
* Please note, numeral symbols cannot lead the name.
|
||||
* They must have indexer that greater than ZERO.
|
||||
*/
|
||||
|
||||
Status Name_CountDown(Name *inst);
|
||||
Status Name_CountDownFor(Name *inst, Name amount);
|
||||
Status Name_CountUp(Name *inst);
|
||||
Status Name_CountUpFor(Name *inst, Name amount);
|
||||
Status Name_EmptyName(Name *inst);
|
||||
Status Name_FormatInflate(Name *inst);
|
||||
Status Name_FormatTrim(Name *inst);
|
||||
Name Name_CalcNameArrayLength(Name **arr);
|
||||
bool Name_IsValid(Name *inst);
|
||||
int Name_Compare(Name *a, Name *b) throws(InvalidName);
|
||||
|
||||
static Status NameOverFlowError = {
|
||||
.description = "An overflow occurred while calculating Name.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.prev = &ArithmeticError
|
||||
};
|
||||
|
||||
static Status InvalidName = {
|
||||
.description = "Given Name was invalid.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.prev = &InvalidParameter
|
||||
};
|
||||
|
||||
#endif /* COMPOUND_NAME_H */
|
Reference in New Issue
Block a user