Alberto Simões 🐪

NAME

CWB::CEQL::String - String-like objects with category information (as return values of DPP rules)

SYNOPSIS

  use CWB::CEQL::String;

  $op = new CWB::CEQL::String ">=";
  $op->type("Operator");
  ## SAME AS: $op = new CWB::CEQL::String ">=", "Operator";

  print "42 $op 0\n"; # prints "42 >= 0"
  if ($op->type eq "Operator") { ... }

  $string = new CWB::CEQL::String "my string", "String";
  $string .= " is beautiful";       # changes string, but not its type
  $string->value("another string"); # $string = "..."; would replace with ordinary string
  print $string->value, "\n";       # access string value explicitly

  $string->attribute("charset", "ascii"); # declare and/or set user-defined attribute
  if ($string->attribute("charset") eq "utf8") { ... }

  $new_string = $string->copy;      # $new_string = $string; would point to same object

DESCRIPTION

** TODO **

Note: automatic conversion to number in numerical expression does usually not work -- use value() method explicitly in this case

METHODS

$obj = new CWB::CEQL::String $string [, $type];

Returns new CWB::CEQL::String object $obj holding string value $string. If $type is given, $obj is assigned to the specified type.

$string = $obj->value;
$string = "$obj";

Return string value of CWB::CEQL::String object $obj. Overloading ensures that this value is accessed automatically if $obj is used in a string context (such as interpolation).

$obj->value($string);

Change string value of $obj. Note that a simple assignment $obj = $string would overwrite $obj with a plain string.

$obj->append($string);
$obj .= $string;

Append $string to string value of $obj.

$obj->type($type);
$type = $obj->type;
$type = ~$obj;
$obj->attribute($name, $value);

Define new user attribute $name with value $value, or change value of existing attribute.

$value = $obj->attribute($name);

Returns value of user attribute $name. It is an error to read an attribute that has not been defined before.

$new_obj = $obj->copy;

Returns a copy of the CWB::CEQL::String object $obj. Note that after a simple assignment $new_obj = $obj, the two variables would contain the same object (so changing one of them would also modify the other).

The copy method makes a flat copy of the internal hash of user attributes. Therefore, complex data structures used as attribute values will be shared between $new_obj and $obj.

$result = $obj->cmp($obj2 [, $reverse]);

The cmp method implements string comparison operators for CWB::CEQL::String objects. The second operand $obj2 must either be a plain string or another CWB::CEQL::String object. If the optional argument $reverse is TRUE, the comparison is reversed (so a string as first operand can be compared with a CWB::CEQL::String object).

COPYRIGHT

Copyright (C) 1999-2010 Stefan Evert [http::/purl.org/stefan.evert]

This software is provided AS IS and the author makes no warranty as to its use and performance. You may use the software, redistribute and modify it under the same terms as Perl itself.