
## Package has dynamic library
useDynLib(RProtoBuf)

importFrom( methods, new )
importFrom( utils, str )
importFrom( "stats", "update")
importFrom( "utils", "packageDescription" )

exportClasses(

	# descriptors
	"Descriptor",
	"FieldDescriptor", "EnumDescriptor",
	"ServiceDescriptor", "MethodDescriptor",
	"FileDescriptor", "EnumValueDescriptor",

	# message
	"Message", 

	# rpc
	"RpcHTTP", 
	
	# virtual streams
	"ZeroCopyInputStream", "ZeroCopyOutputStream",
	
	# concrete implementations
	"ArrayInputStream", "ArrayOutputStream", 
	"FileInputStream", "FileOutputStream", 
	"ConnectionInputStream", "ConnectionOutputStream"
	
	)

exportMethods( "new", "[[", "[[<-", "$", "$<-", "show",
	"serialize", "as.character", "update",
	"has", "clone", "merge", "read", "readASCII", "bytesize",
	"length", "str", "isInitialized",
	"clear", "size", "size<-", "swap",
	"descriptor", "set", "fetch", "toString",
	"identical", "==", "!=", "all.equal", "add",
	"fileDescriptor", "name", "flush", "close", 

	"containing_type",
	"field_count", "nested_type_count", "enum_type_count",
	"field", "nested_type", "enum_type",

	# FieldDescriptor
	"is_extension", "number", "label",
	"is_required", "is_repeated", "is_optional",
	"has_default_value", "default_value",
	"message_type", "enum_type",

	# EnumDescriptor
	"value_count", "value",

	# ServiceDescriptor
	"method_count", "method",

	# MethodDescriptor
	"input_type", "output_type",

	# rpc
	"invoke", 
	
	# streams
	"Next", "ByteCount", "BackUp", "Skip", 
	"ArrayInputStream", "ArrayOutputStream", "FileInputStream", "FileOutputStream", 
	"GetErrno", "SetCloseOnDelete", 
	"ConnectionInputStream", "ConnectionOutputStream", 
	"ReadRaw", "ReadString", "ReadVarint32", 
	"ReadLittleEndian32", "ReadLittleEndian64", "ReadVarint64", 
	"WriteRaw", "WriteString", "WriteLittleEndian32", 
	"WriteLittleEndian64", "WriteVarint32", "WriteVarint64"
	
	
	)

export( "P", "readProtoFiles", "asMessage" )

if( exists( ".DollarNames", asNamespace("utils") ) ) importFrom( utils, .DollarNames )
S3method(.DollarNames, Message )
S3method(.DollarNames, Descriptor )
S3method(.DollarNames, EnumDescriptor )
S3method(.DollarNames, FileDescriptor )
S3method(.DollarNames, FieldDescriptor )
S3method(.DollarNames, ServiceDescriptor )
S3method(.DollarNames, MethodDescriptor )
S3method(.DollarNames, ZeroCopyInputStream  )
S3method(.DollarNames, ZeroCopyOutputStream )

S3method( with, Message )
S3method( within, Message)

S3method( as.list, Message )
S3method( as.list, Descriptor )
S3method( as.list, EnumDescriptor )
S3method( as.list, FileDescriptor )
S3method( as.list, ServiceDescriptor )

# constants
exportPattern( "^TYPE_" )
exportPattern( "^CPPTYPE_" )
exportPattern( "^LABEL_" )

# export( run_unit_tests )

