Glib

 view release on metacpan or  search on metacpan

GKeyFile.xs  view on Meta::CPAN


	/* tie the key_file to our hash using some magic */
	_gperl_attach_mg ((SV*) key, key_file);

	/* wrap it, bless it, ship it. */
	sv = newRV_noinc ((SV*) key);

	stash = gv_stashpv ("Glib::KeyFile", TRUE);
	sv_bless (sv, stash);

	return sv;
}

GKeyFile *
SvGKeyFile (SV * sv)
{
	MAGIC * mg;
	if (!gperl_sv_is_ref (sv) || !(mg = _gperl_find_mg (SvRV (sv))))
		return NULL;
	return (GKeyFile *) mg->mg_ptr;
}

MODULE = Glib::KeyFile	PACKAGE = Glib::KeyFile	PREFIX = g_key_file_

=for object Glib::KeyFile Parser for .ini-like files
=cut

=for position SYNOPSIS

=head1 SYNOPSIS

  use Glib;

  $data .= $_ while (<DATA>);

  $f = Glib::KeyFile->new;
  $f->load_from_data($data);
  if ($f->has_group('Main') && $f->has_key('Main', 'someotherkey')) {
      $val = $f->get_integer('Main', 'someotherkey');
      print $val . "\n";
  }
  0;
  __DATA__
  # a comment
  [MainSection]
  somekey=somevalue
  someotherkey=42
  someboolkey=true
  listkey=1;1;2;3;5;8;13;21
  localekey=Good Morning
  localekey[it]=Buon giorno
  localekey[es]=Buenas dias
  localekey[fr]=Bonjour

=for position DESCRIPTION

=head1 DESCRIPTION

B<Glib::KeyFile> lets you parse, edit or create files containing groups of
key-value pairs, which we call key files for lack of a better name. Several
freedesktop.org specifications use key files now, e.g the Desktop Entry
Specification and the Icon Theme Specification.

The syntax of key files is described in detail in the Desktop Entry
Specification, here is a quick summary: Key files consists of groups of
key-value pairs, interspersed with comments.

=cut

BOOT:
	gperl_register_fundamental (GPERL_TYPE_KEY_FILE_FLAGS,
				    "Glib::KeyFileFlags");

void
DESTROY (GKeyFile * key_file)
    CODE:
    	g_key_file_free (key_file);

GKeyFile*
g_key_file_new (class)
    C_ARGS:
    	/* void */

# unneded
#void      g_key_file_free                   (GKeyFile             *key_file);

=for apidoc
Sets the list separator character.
=cut
void
g_key_file_set_list_separator (key_file, separator)
	GKeyFile * key_file
	gchar separator

=for enum Glib::KeyFileFlags
=cut

=for apidoc __gerror__
Parses a key file.
=cut
gboolean
g_key_file_load_from_file (key_file, file, flags)
	GKeyFile * key_file
	const gchar * file
	GKeyFileFlags flags
    PREINIT:
    	GError *err = NULL;
    CODE:
    	RETVAL = g_key_file_load_from_file (key_file, file, flags, &err);
	if (err)
		gperl_croak_gerror (NULL, err);
    OUTPUT:
    	RETVAL

=for apidoc __gerror__
Parses a string containing a key file structure.
=cut
gboolean
g_key_file_load_from_data (key_file, buf, flags)
	GKeyFile * key_file
	SV * buf



( run in 0.785 second using v1.01-cache-2.11-cpan-39bf76dae61 )