
## Package has dynamic library
useDynLib("RProtoBuf", .registration=TRUE)

importFrom("methods", "new", "show", "as", "is")
importFrom("utils", "str", "packageDescription", "packageVersion")
importFrom("stats", "update")
importFrom("tools", "file_path_as_absolute")
#importFrom("RCurl", "basicTextGatherer", "curlPerform")
importFrom("Rcpp", "evalCpp")

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", "readJSON",
	"bytesize", "length", "str", "isInitialized",
	"clear", "size", "size<-", "swap",
	"descriptor", "set", "fetch", "toString", "toJSON",
	"identical", "==", "!=", "all.equal", "add",
	"fileDescriptor", "name", "names", "flush", "close",
        "setExtension", "getExtension",

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

	# FieldDescriptor
	"is_extension", "number",
	"is_required", "is_repeated",
	"has_default_value", "default_value",
	"message_type", "enum_type", "type", "cpp_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", "readProtoFiles2", "resetDescriptorPool", "asMessage")

importFrom(utils, .DollarNames)
S3method(.DollarNames, Message)
S3method(.DollarNames, Descriptor)
S3method(.DollarNames, EnumDescriptor)
S3method(.DollarNames, EnumValueDescriptor)
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)

S3method(all.equal, Message)

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

# copied from RProtoBufUtils
export("serialize_pb", "unserialize_pb", "can_serialize_pb")

# export(run_unit_tests)
