| 1 | package CORBA::IOP::TaggedProfile; | ||
| 2 | |||
| 3 | require 5.001; | ||
| 4 | |||
| 5 | use CORBA::IOP::Util; | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | |||
| 9 | |||
| 10 | sub new { | ||
| 11 | my $class = shift; | ||
| 12 | my $self = {}; | ||
| 13 | |||
| 14 | $self->{version_major} = 0; | ||
| 15 | $self->{version_minor} = 0; | ||
| 16 | $self->{host} = 0; | ||
| 17 | $self->{port} = 0; | ||
| 18 | $self->{obj_key} = 0; | ||
| 19 | |||
| 20 | return bless $self, $class; | ||
| 21 | } | ||
| 22 | |||
| 23 | |||
| 24 | sub parseIOR { | ||
| 25 | my $self = shift; | ||
| 26 | my ($ior, $byte, $little_endian) = @_; | ||
| 27 | |||
| 28 | ($self->{version_major}, $byte) = &decode_number($ior, $byte, 1, $little_endian); | ||
| 29 | ($self->{version_minor}, $byte) = &decode_number($ior, $byte, 1, $little_endian); | ||
| 30 | |||
| 31 | ($self->{host}, $byte) = &decode_string($ior, $byte, $little_endian); | ||
| 32 | |||
| 33 | ($self->{port}, $byte) = &decode_number($ior, $byte, 2, $little_endian); | ||
| 34 | |||
| 35 | ($self->{obj_key}, $byte) = &decode_encapsulation($ior, $byte, $little_endian); | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | sub printHash { | ||
| 40 | my $self = shift; | ||
| 41 | my ($key, $value); | ||
| 42 | |||
| 43 | while (($key, $value) = each %$self) { | ||
| 44 | print "$key = $value\n"; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | |||
| 49 | sub stringifyIOR { | ||
| 50 | my $self = shift; | ||
| 51 | my ($length, $little_endian) = @_; | ||
| 52 | |||
| 53 | my ($ior); | ||
| 54 | $ior = ""; | ||
| 55 | |||
| 56 | $ior .= encode_number($length + length($ior), 1, $little_endian, $self->{version_major}); | ||
| 57 | $ior .= encode_number($length + length($ior), 1, $little_endian, $self->{version_minor}); | ||
| 58 | |||
| 59 | $ior .= encode_string($length + length($ior), $little_endian, $self->{host}); | ||
| 60 | |||
| 61 | $ior .= encode_number($length + length($ior), 2, $little_endian, $self->{port}); | ||
| 62 | |||
| 63 | $ior .= encode_encapsulation($length + length($ior), $little_endian, $self->{obj_key}); | ||
| 64 | |||
| 65 | return $ior; | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | 1; |