hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.12k stars 366 forks source link

@include directive failed? #235

Closed bethebest0622 closed 11 months ago

bethebest0622 commented 12 months ago

i used @include directive, learn from here: https://hyperrealm.github.io/libconfig/libconfig_manual.html#Include-Directives

a.cfg

a = 1;
b = "";
c = {id = "asd"; key = 2; @include "./c.cfg"};

c.cfg

q = "good";

main.cpp

#include <libconfig.h++>

int main() {
  libconfig::Config cfg;
  cfg.readFile("a.cfg");
}

error message

terminate called after throwing an instance of 'libconfig::ParseException'
  what():  ParseException
[1]    441940 abort      ./a.out

it's ok if the a.cfg looks like:

a = 1;
b = "";
@include "./c.cfg"

could you help on this?

hyperrealm commented 12 months ago

As stated in the documentation:

An include directive must appear on its own line in the input.

On Wed, Dec 6, 2023 at 8:05 AM bethebest0622 @.***> wrote:

— Reply to this email directly, view it on GitHub https://github.com/hyperrealm/libconfig/issues/235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR4MI55XDBHAGQLKSQ5L6TYICCSPAVCNFSM6AAAAABAJQ3WYCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZDQNZWGIYTAOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Mark Lindner http://www.hyperrealm.com/

bethebest0622 commented 12 months ago

ok.....

@hyperrealm Do we have the plan to add the one line @include support?

hyperrealm commented 11 months ago

There are no plans to do that, as it would significantly complicate the parser.