TSCL.Parser
1.3.2
See the version list below for details.
dotnet add package TSCL.Parser --version 1.3.2
NuGet\Install-Package TSCL.Parser -Version 1.3.2
<PackageReference Include="TSCL.Parser" Version="1.3.2" />
<PackageVersion Include="TSCL.Parser" Version="1.3.2" />
<PackageReference Include="TSCL.Parser" />
paket add TSCL.Parser --version 1.3.2
#r "nuget: TSCL.Parser, 1.3.2"
#:package TSCL.Parser@1.3.2
#addin nuget:?package=TSCL.Parser&version=1.3.2
#tool nuget:?package=TSCL.Parser&version=1.3.2
TSCL
TSCL or Tezz's Simple Configuration Language is a flat Configuration langauge that is mainly used for configurations and other similar ventures. TSCL doesn't have braces and nested braces which could look confusing and messy in the long run.
Instead TSCL has Pointers that points to a Section. In TSCL, this simple langauge contains only 4 parts:
- Sections
- Objects
- Arrays
- Pointers
Sections
Sections are basically namespaces that you can group your objects,arrays and pointers.
[Section-Name]
ObjectName="Value"
Object2= 21
Array="Dave","John","Micheal"
Next=@NextSection
[NextSection]
isActive=false
Members=30
Objects
You can add as many objects as you want in any section, TSCL has 3 object types:
- String
- Integer
- Boolean
Arrays
TSCL arrays are strictly strings, so it can be parsed serialized and deserialized easily. You can declare an array by simply Adding commas after you declared your array name:
[Section]
Array="One","Two","Three"
Pointers
Instead of nesting with messy curly braces or retyping a section inside a section, You can just use pointers instead. Pointers are basically objects that point to a Section.
[Section1]
Point=@Section2
[Section2]
isActive=true
Note: Your Pointer value has to always have a '@' symbol at the very start, other wise its just a regular object. And also your Pointer has to have the same name as your target Section
Modes
TSCL has two modes you can toggle in the Initializer class. Simply set the static bool "isUniversal" to true or false, true if you want to use TSCL's SetFile in Initializer to pass your file, that way all 3 classes will use Initializers Filename instead of their own in their constructor. However when false the 3 classes wont use the initializers, instead it will use what you pass on its constructor.
There is also "isVerbose", which basically prints all the errors in your tscl file. by setting it to true, it prints the errors on your console, but if its false it does not.
Note: Both isVerbose and isUniversal is false by default.
Usage
To use TSCL just add the namespace on top of your file and call Write to serialize and Read to deserialize. You can also use the Token struct if you want to parse an entire sections objects and use em on your program/app.
using TSCL; // Just Include this namespace to use: Read,Write and Modify
namespace Test{
Public Class Test{
string[] arr;
public Test(string filename){
Initializer.setFile("FilePath.tscl") //make sure you set your file before using: Read, Write and Modify
Token[] tokens;
//Deserializing
Read read = new Read()// Initialize read
read.setSection("Section1"); //We then set which section to start with
int data = read.GetValue<int>("Object_Name"); //after setting we can grab our datas value with the GetValue().
arr = read.GetArrayValue<array>("Array_Name"); //Or if its an array we can go ahead and use the GetArrayValue().
tokens = read.getSectionObjects("NextSection"); // We can also grab objects of Sections and manually use them.
// in the parameters you can put a section name to advance to that section or use the current section by
// leaving the parameter blank.
initiateFile();
}
public void initiateFile(){ // Serializing
using(Write write = new Write()// Initialize Write
write.AddSection("SectionName"); // This is how we add our section
write.SetSection("SectionName"); //After adding our section, we need to set to use it, otherwise our current section is null
write.AddObject("key","value",Types.OBJECT) // this is how add our objects, arrays and pointers to our section, object value can be
//int, bool or string. But array values are only string.
write.WriteToFile(); //After we are done, we call the writetofile method, to confirm it.
}
public void FileModification() // File Modification
{
Modify mod = new Modify() //always make sure the file exists
mod.SetSection("Section1"); // Always set your target section before modifying
mod.ModifyObject("Object_Name","NewValue"); // Modify
}
}
}
Logo
License
This Project is under the GNU General Public License. See the License File for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Changes:
- Improved Tokenizing
- Ignores invalid lines
- Added better error handling
- Added a initiater class for universal filename for all 3 classes
- Ignores comment '#'
- Handles negative numbers now
1.3
- Added missing File.WriteAllLines in Modify class.
- Added a List of Filenames in Initialize class and AddFile and UseFile methods
- Initailized uninitialized members
- Added guard clauses in addFile and useFile
- Added an Universal in initializer class, for instance based file operation.
- fixed ".tscl" to "tscl" in guard clause.
- Added support for net 9.0 - 8.0
- Changed WriteAllLines to StreamWriter in Write Class
- Optimized conditions in Reads Tokenizer
- Fixed File not set Error and extension checking
- Updated Read classes initialize read to iterate through keypair values.
- getObjectData returns token array when getting a pointer.
1.3.1
- Added isVerbose for logging
- Set both isVerbose and isUniversal to false
- fixed path issue in Modify class
1.3.2
- Added a Automatic typcaster
- getObjectValue and getArrayValue are now internal.
New methods GetValue and GetArrayValue replaces them.