### Home Classes Methods

### In Files

- lib/dbus/type.rb

### Parent

Object

### Methods

- ::new
- #nextchar
- #parse
- #parse_one

### Files

- README

### Class/Module Index

Quicksearch

- DBus
- DBus::ASessionBus
- DBus::ASystemBus
- DBus::AuthenticationFailed
- DBus::Authenticator
- DBus::Client
- DBus::Connection
- DBus::Connection::NameRequestError
- DBus::DBusCookieSHA1
- DBus::Error
- DBus::ErrorMessage
- DBus::External
- DBus::FormalParameter
- DBus::IncompleteBufferException
- DBus::Interface
- DBus::InterfaceElement
- DBus::IntrospectXMLParser
- DBus::InvalidClassDefinition
- DBus::InvalidDestinationName
- DBus::InvalidIntrospectionData
- DBus::InvalidMethodName
- DBus::InvalidPacketException
- DBus::InvalidParameters
- DBus::Main
- DBus::MatchRule
- DBus::MatchRuleException
- DBus::Message
- DBus::Method
- DBus::MethodNotImplemented
- DBus::MethodReturnMessage
- DBus::Node
- DBus::Object
- DBus::Object::UndefinedInterface
- DBus::PacketMarshaller
- DBus::PacketUnmarshaller
- DBus::ProxyObject
- DBus::ProxyObjectFactory
- DBus::ProxyObjectInterface
- DBus::RemoteBus
- DBus::Service
- DBus::SessionBus
- DBus::Signal
- DBus::SystemBus
- DBus::Type
- DBus::Type::Parser
- DBus::Type::SignatureException
- DBus::Type::Type
- DBus::TypeException
- DBus::UnknownSignal
- Integer

No matching classes.

# DBus::Type::Parser

# D-Bus type parser class

Helper class to parse a type signature in the protocol.

### Public Class Methods

new(signature) click to toggle source

Create a new parser for the given signature.

    # File lib/dbus/type.rb, line 158
    def initialize(signature)
      @signature = signature
      @idx = 0
    end

### Public Instance Methods

nextchar() click to toggle source

Returns the next character from the signature.

    # File lib/dbus/type.rb, line 164
    def nextchar
      c = @signature[@idx]
      @idx += 1
      c
    end

parse() click to toggle source

Parse the entire signature, return a DBus::Type object.

    # File lib/dbus/type.rb, line 197
    def parse
      @idx = 0
      ret = Array.new
      while (c = nextchar)
        ret << parse_one(c)
      end
      ret
    end

parse_one(c) click to toggle source

Parse one character c of the signature.

    # File lib/dbus/type.rb, line 171
    def parse_one(c)
      res = nil
      case c
      when aa
        res = Type.new(ARRAY)
        child = parse_one(nextchar)
        res << child
      when ((
        res = Type.new(STRUCT)
        while (c = nextchar) != nil and c != ))
          res << parse_one(c)
        end
        raise SignatureException, "Parse error in #{@signature}" if c == nil
      when {{
        res = Type.new(DICT_ENTRY)
        while (c = nextchar) != nil and c != }}
          res << parse_one(c)
        end
        raise SignatureException, "Parse error in #{@signature}" if c == nil
      else
        res = Type.new(c)
      end
      res
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.