{"id":28956644,"url":"https://github.com/nimaoth/omcl","last_synced_at":"2025-06-23T21:40:28.841Z","repository":{"id":78561354,"uuid":"153097763","full_name":"Nimaoth/OMCL","owner":"Nimaoth","description":"A simple configuration language","archived":false,"fork":false,"pushed_at":"2018-10-17T17:01:23.000Z","size":55,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-11T02:18:17.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nimaoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-10-15T10:55:39.000Z","updated_at":"2018-10-17T17:01:25.000Z","dependencies_parsed_at":"2023-02-28T23:30:24.808Z","dependency_job_id":null,"html_url":"https://github.com/Nimaoth/OMCL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Nimaoth/OMCL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimaoth%2FOMCL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimaoth%2FOMCL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimaoth%2FOMCL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimaoth%2FOMCL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nimaoth","download_url":"https://codeload.github.com/Nimaoth/OMCL/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimaoth%2FOMCL/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261561176,"owners_count":23177543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-23T21:40:28.095Z","updated_at":"2025-06-23T21:40:28.806Z","avatar_url":"https://github.com/Nimaoth.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OMCL\n\nLatest Version: 0.0.5\n\n[Available as NuGet package](https://www.nuget.org/packages/OMCLConfig)\n\nOMCL is a simple configuration language.\nIt supports comments, maps, arrays, strings, integers, floats, booleans and a special value, 'none', indication that no value is present.\n\nEach value can be tagged.\n\n.omcl files have to be valid UTF-8 files.\n\nThe top level of an omcl file is an object, where the curly braces can be omitted.\n\n### Comments\nThere are two types of comments.\n\nLine comments begin with ```//```:\n```javascript\n// This is a comment\n```\n\nBlock comments are between `/*` and `*/`, and they can also be nested:\n```javascript\n/*\nThis is a block comment\n    /*\n        Block comments can be nested\n    */\n*/\n```\n\n### Objects\nObjects are denoted by a pair of braces '{}'\n```javascript\n// Objects begin with an open brace\n{\n    // properties\n}\n```\n\n#### Properties\nObjects contain properties. Each property has a name and a value, separated by `=`\n\nIf the value is an object or an array, the `=` can be omitted.\n```javascript\n{\n    // object with `=`\n    property1 = {}\n\n    // object without `=`\n    // This is equivalent to property1\n    property2 {}\n\n    property3 = []\n    property4 []\n\n    property5 = \"this is a string\"\n\n    \"this property name contains whitespace\" = \"some value\"\n}\n```\n\nPropery names can contain any character except `\"` if they are surrounded by double quotes, and `'` if they are surrounded by single quotes.\n\n\nIf a property name only contains the characters `a-z`, `A-Z`, `0-9`, `_` or `-`, it does not need to be surrounded with quotes.\n\n### Lists\nObjects are a list of unnamed values. Values have to separated by commas or a line break (`\\n` or `\\r\\n`)\n\n```javascript\n// a list of integers\n[ 1, 2, 3 ]\n\n// the same list, but separated by line breaks\n// instead of commas\n[\n    1\n    2\n    3\n]\n\n// lists can contain values of different types\n[\n    1\n    \"a string\"\n    'another string'\n    {\n        // a object\n    }\n\n    // a nested list\n    [ \"this\", \"is\", 'a', 'list' ]\n]\n\n// commas linebreaks can be used together\n// trailing commas are allowed\n[\n    1, 2, 3\n    4, 5, 6,\n    9,\n    10,\n    11\n    12,\n]\n```\n\n### Strings\nStrings a character sequences surrounded by either single quotes (`'`) or double quotes (`\"`).\nThey can contain all valid unicode codepoints except for the quotation character, even linebreaks.\n\nString literals can be concatenated.\n\n```\n// A simple string literal\n\"This is a string literal\"\n'This is a string literal'\n\n// With line breaks\n\"This string\ncontains linebreaks.\nThis is awesome\"\n\n// if you want to represent a string which contains both single and double quotes, you can use string concatenation:\n\"single quotes: '', \" 'double quotes \"\"'\n//                   ^ Here the string concatenation happens\n\n// the resulting string will look like this:\n// single quotes: '', double quotes \"\"\n```\n\n### Booleans\nA bool can be either `true` or `false`\n```javascript\ntrue\nfalse\n```\n\n### Integers\nIntegers are 64 bit signed numbers.\nThey can contain underscores to make them more readable.\nUnderscores can not appear at the beginning or end of the number literal. Hexadecimal numbers begin with `0x`, binary numbers with `0b` and octal numbers with `0o`\n```\n123\n5_000_000\n0xff        // decimal: 255\n0b1000_1000 // decimal: 136\n0o25        // decimal: 21\n```\n\n### Floats\nFloats are 64 bit double presicion floating point numbers.\nThe rules for underscores are similiar to integers.\n```\n1.0\n5_000_000.356_125\n9.0e19\n123e-5_000\n```\n\n### None\n`none` is a special literal representing no value\n\n### Tags\nEach value can be tagged by prefixing it with a tag.\nTags have the form `!tag_name`, where tag_name can contain `a-z`, `A-Z`, `0-9`, `_` or `-`, but can not start or end with `_` or `-`\n```javascript\n// tag an object with `a_tag`\n!a_tag {\n    // ...\n}\n\n// multiple tags\n!a !b !c { /* ... */ }\n\n!regex \"![a-zA-Z0-9]([a-zA-Z0-9-_]*[a-zA-Z0-9])*\"\n\n!int-list [ 1, 2, 3, 4, 5 ]\n```\n\n## Examples\n```javascript\n// properties\nid = \"Enemy1\"\nactive = true\nparent = none\n\n// use tags to specify the type of component\ncomponents [\n    !health_component {\n        health = 100\n    }\n\n    !move_component {\n        // ...\n    }\n\n    // ...\n]\n```\n\n```javascript\n// configuration for an imaginary service\n\nendpoint = \"some.random.url/some/path\"\nport     = 9876\nauto_reload_config = true\nreload_config_interval = !time_span \"01:00\" // 1 minute\n\nauthentication {\n    username = \"...\"\n    password = \"...\"\n}\n\ncomponents [\n    !some_compontent_1 {\n        // compontent specific config\n    }\n    \n    !some_compontent_2 {\n        // compontent specific config\n    }\n]\n```\n\n## C# API examples\n\nParsing a .omcl file into C#-Objects can be done via `OMCL.Serialization.Parser`.\nParsing into a custom class structure will be implemented in future versions (available since version 0.0.5).\nSerializing an object to a string or a file can be done with the `OMCL.Serialization.Serializer` class.\n\n```csharp\nusing System;\nusing System.Text;\nusing OMCL.Data;\nusing OMCL.Serialization;\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        // parse from file\n        Parser parser = Parser.FromFile(\"example.omcl\");\n        OMCLObject obj = parser.ParseObject();\n\n        // parse from string (since version 0.0.4)\n        parser = Parser.FromString(@\"\n            prop1 = 1\n            prop2 = true\n            prop3 {\n                test1 = []\n                test2 = {}\n                test3 = none\n            }\n        \");\n        obj = parser.ParseObject();\n\n        // serialize to string\n        var stringBuilder = new StringBuilder();\n        Serializer serializer = Serializer.ToStringBuilder(stringBuilder);\n        serializer.Serialize(obj);\n\n        Console.WriteLine(stringBuilder);\n\n        // serialize to file\n        serializer = Serializer.ToFile(\"filename.omcl\");\n        serializer.Serialize(obj);\n    }\n}\n```\n\nSerialization into a custom class structure:\n```csharp\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Numerics;\nusing System.Text;\nusing OMCL.Data;\nusing OMCL.Serialization;\n\nclass Program\n{\n    // data structure\n    class Person {\n        public string Name { get; set; }\n        public string LastName { get; set; }\n        public Gender Gender { get; set; }\n        public DateTime DateOfBirth;\n        public float Height { get; set; }\n        public string[] NickNames;\n        public List\u003cPerson\u003e Children;\n        public BigInteger HairCount;\n        public List\u003cHobby\u003e Hobbies;\n    }\n\n    enum Gender {\n        m, w\n    }\n\n    class Hobby {\n        public string Name { get; set; }\n    }\n\n    class Soccer : Hobby {\n        public string Position { get; set; }\n    }\n\n    class Tennis : Hobby {\n        public bool Good { get; set; }\n    }\n\n    // converters\n    class DateTimeConverter : IStringConverter {\n        public object ConvertString(List\u003cstring\u003e tags, string str) {\n            return DateTime.ParseExact(str, \"yyyy/MM/dd\", CultureInfo.InvariantCulture);\n        }\n    }\n\n    class BigIntegerConverter : IStringConverter {\n        public object ConvertString(List\u003cstring\u003e tags, string str) {\n            return BigInteger.Parse(str);\n        }\n    }\n\n    class HobbyConverter : IObjectConverter {\n        public bool CanConvert(List\u003cstring\u003e tags, OMCLObject obj) {\n            return tags.Count == 1;\n        }\n\n        public object CreateInstance(List\u003cstring\u003e tags) {\n            var hobby = tags[0];\n            switch (hobby) {\n            case \"Soccer\": return new Soccer();\n            case \"Tennis\": return new Tennis();\n            default: return new Hobby();\n            }\n        }\n    }\n\n    // main\n    static void Main(string[] args)\n    {\n        var parser = Parser.FromString(@\"\n            Name = 'Jon'\n            LastName = 'Doe'\n            Gender = 'm'\n            Height = 1.82\n            DateOfBirth = '1983/01/16'\n            NickNames [ 'The One', 'And Only' ]\n            Children [\n                {\n                    Name = 'Max'\n                    LastName = 'Doe'\n                    Gender = 'm'\n                    // ...\n                }\n                {\n                    Name = 'Gina'\n                    LastName = 'Doe'\n                    Gender = 'w'\n                    // ...\n                }\n            ]\n            HairCount = '12345678987654321234567898765432123456789'\n            Hobbies [\n                !Soccer {\n                    Name = 'Soccer'\n                    Position = 'Defense'\n                }\n                !Tennis {\n                    Name = 'Tennis'\n                    Good = false\n                }\n            ]\n        \");\n\n        Deserializer deserializer = new Deserializer();\n        deserializer.AddStringConverter\u003cDateTime\u003e(new DateTimeConverter());\n        deserializer.AddStringConverter\u003cBigInteger\u003e(new BigIntegerConverter());\n        deserializer.AddObjectConverter\u003cHobby\u003e(new HobbyConverter());\n\n        var person = deserializer.Deserialize\u003cPerson\u003e(parser);\n        // ...\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimaoth%2Fomcl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnimaoth%2Fomcl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimaoth%2Fomcl/lists"}