<commit_before># cstructinfo
Tool used to collect structs and functions info from c/c++ sources to JSON.

## Usage
Use tool like this:
```
cstructinfo example.c -I/your/include/path \
                  -D_AND_OTHER_COMPILER_OPTIONS_ > output.json
```

Do not separate compiler options. For example
```
cstructinfo example.c -I /your/include/path \
                  -D _AND_OTHER_COMPILER_OPTIONS_ > output.json
```
this do not work.


## Build
- depends from libclang-3.8, llvm-3.8, ncurses
  (debian: libclang-dev, llvm-dev, libncursesw5-dev)

## Example
Input file example.c:
```
#include <stdio.h>
#include <stdlib.h>

typedef struct foo
{
    /// Comment about a
    int a;
    int b; ///< Comment about b
    int c;
}foo;

/*!
 * It is foo2 description
 * */
typedef struct foo2
{
    size_t numFoos;
    foo foos[10][20];
}foo2;

/**
 * @brief Print foo contents.
 * @param f struct to print
 * @return Your return message
 */
int bar(const foo* f)
{
    printf("foo contains: a = %d, b =%d, c = %d\n", f->a, f->b, f->c);
    return 0;
}
```
Command:
```
cstructinfo example.c
```

Output:
```
{
    "structs": [
        {
            "name": "foo",
            "comment": "",
            "fields": [
                {
                    "field": "a",
                    "type": "int",
                    "comment": "Comment about a"
                },
                {
                    "field": "b",
                    "type": "int",
                    "comment": "Comment about b"
                },
                {
                    "field": "c",
                    "type": "int",
                    "comment": ""
                }
            ]
        },
        {
            "name": "foo2",
            "comment": "It is foo2 description",
            "fields": [
                {
                    "field": "numFoos",
                    "type": "int",
                    "comment": ""
                },
                {
                    "field": "foos",
                    "type": "foo [10][20]",
                    "comment": "",
                    "array": {
                        "elemType": "foo",
                        "size": [
                            "10",
                            "20"
                        ]
                    }
                }
            ]
        }
    ],
    "functions": [
        {
            "name": "bar",
            "retval": "int",
            "retcomment": "Your return message",
            "comment": "Print foo contents.",
            "params": [
                {
                    "param": "f",
                    "type": "const foo *",
                    "comment": "struct to print"
                }
            ]
        }
    ]
}
```

## On errors
If error messages appear on standard headers (stddef.h, stdargs.h etc)
you can specify COMPILER_PATH of your compiler for example:

```
./cstructinfo example.c -I/usr/lib/clang/3.8.1/include/
```
or
```
./cstructinfo example.c -I/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include
```

You can know what path exactly you need by typing command:
```
echo | gcc  -E -v -
```
or
```
echo | clang  -E -v -
```
see section "#include <...> search starts here:"
<commit_msg>add parameters info to README<commit_after># cstructinfo
Tool used to collect structs and functions info from c/c++ sources to JSON.

## Usage
Use tool like this:
```
cstructinfo example.c -I/your/include/path \
                  -D_AND_OTHER_COMPILER_OPTIONS_ > output.json
```

Do not separate compiler options. For example
```
cstructinfo example.c -I /your/include/path \
                  -D _AND_OTHER_COMPILER_OPTIONS_ > output.json
```
this do not work.

## Parameters
- --main-only - do not write any structs or functions from included files output, only from files specified.
- --no-structs - do not write any struct info to output. Do not create "structs" section.
- --no-functions - do not write any function info to output. Do not create "functions" section.


## Example
Input file example.c:
```
#include <stdio.h>
#include <stdlib.h>

typedef struct foo
{
    /// Comment about a
    int a;
    int b; ///< Comment about b
    int c;
}foo;

/*!
 * It is foo2 description
 * */
typedef struct foo2
{
    size_t numFoos;
    foo foos[10][20];
}foo2;

/**
 * @brief Print foo contents.
 * @param f struct to print
 * @return Your return message
 */
int bar(const foo* f)
{
    printf("foo contains: a = %d, b =%d, c = %d\n", f->a, f->b, f->c);
    return 0;
}
```
Command:
```
cstructinfo example.c
```

Output:
```
{
    "structs": [
        {
            "name": "foo",
            "comment": "",
            "fields": [
                {
                    "field": "a",
                    "type": "int",
                    "comment": "Comment about a"
                },
                {
                    "field": "b",
                    "type": "int",
                    "comment": "Comment about b"
                },
                {
                    "field": "c",
                    "type": "int",
                    "comment": ""
                }
            ]
        },
        {
            "name": "foo2",
            "comment": "It is foo2 description",
            "fields": [
                {
                    "field": "numFoos",
                    "type": "int",
                    "comment": ""
                },
                {
                    "field": "foos",
                    "type": "foo [10][20]",
                    "comment": "",
                    "array": {
                        "elemType": "foo",
                        "size": [
                            "10",
                            "20"
                        ]
                    }
                }
            ]
        }
    ],
    "functions": [
        {
            "name": "bar",
            "retval": "int",
            "retcomment": "Your return message",
            "comment": "Print foo contents.",
            "params": [
                {
                    "param": "f",
                    "type": "const foo *",
                    "comment": "struct to print"
                }
            ]
        }
    ]
}
```

## Build
- depends from libclang-3.8, llvm-3.8, ncurses
  (debian: libclang-dev, llvm-dev, libncursesw5-dev)


## On errors
If error messages appear on standard headers (stddef.h, stdargs.h etc)
you can specify COMPILER_PATH of your compiler for example:

```
./cstructinfo example.c -I/usr/lib/clang/3.8.1/include/
```
or
```
./cstructinfo example.c -I/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include
```

You can know what path exactly you need by typing command:
```
echo | gcc  -E -v -
```
or
```
echo | clang  -E -v -
```
see section "#include <...> search starts here:"

{'fraction_non_alphanumeric': 0.14247748412815592, 'fraction_numerical': 0.009744574043998228, 'mean_word_length': 1.248257550614006, 'pattern_counts': {'":': 68, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2157569', 'n_tokens_mistral': 2124, 'n_tokens_neox': 1966, 'n_words': 551}