PBDataWriter.h
 1  /*
 2   This file is part of Darling.
 3  
 4   Copyright (C) 2020 Lubos Dolezel
 5  
 6   Darling is free software: you can redistribute it and/or modify
 7   it under the terms of the GNU General Public License as published by
 8   the Free Software Foundation, either version 3 of the License, or
 9   (at your option) any later version.
10  
11   Darling is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15  
16   You should have received a copy of the GNU General Public License
17   along with Darling.  If not, see <http://www.gnu.org/licenses/>.
18  */
19  
20  #include <Foundation/Foundation.h>
21  
22  typedef int PBDataReaderMark;
23  
24  @class PBCodable;
25  
26  @interface PBDataWriter : NSObject
27  
28  @end
29  
30  void PBDataWriterWriteStringField(PBDataWriter* writer, NSString* string, uint32_t tag);
31  void PBDataWriterWriteBOOLField(PBDataWriter* writer, BOOL boolean, uint32_t tag);
32  
33  void PBDataWriterPlaceMark(PBDataWriter* writer, PBDataReaderMark* mark, uint32_t tag);
34  void PBDataWriterRecallMark(PBDataWriter* writer, PBDataReaderMark* mark, uint32_t tag);
35  // not sure what the varint type is here
36  void PBDataWriterWriteBareVarint(PBDataWriter* writer, void* value, uint32_t tag);
37  void PBDataWriterWriteDataField(PBDataWriter* writer, NSData* value, uint32_t tag);
38  void PBDataWriterWriteDoubleField(PBDataWriter* writer, double value, uint32_t tag);
39  void PBDataWriterWriteFixed32Field(PBDataWriter* writer, int32_t value, uint32_t tag);
40  void PBDataWriterWriteFixed64Field(PBDataWriter* writer, int64_t value, uint32_t tag);
41  void PBDataWriterWriteFloatField(PBDataWriter* writer, float value, uint32_t tag);
42  void PBDataWriterWriteInt32Field(PBDataWriter* writer, int32_t value, uint32_t tag);
43  void PBDataWriterWriteInt64Field(PBDataWriter* writer, int64_t value, uint32_t tag);
44  void PBDataWriterWriteSfixed32Field(PBDataWriter* writer, int32_t value, uint32_t tag);
45  void PBDataWriterWriteSfixed64Field(PBDataWriter* writer, int64_t value, uint32_t tag);
46  void PBDataWriterWriteSint32Field(PBDataWriter* writer, int32_t value, uint32_t tag);
47  void PBDataWriterWriteSint64Field(PBDataWriter* writer, int64_t value, uint32_t tag);
48  // also unsure here
49  void PBDataWriterWriteSubgroup(PBDataWriter* writer, void* group, uint32_t tag);
50  void PBDataWriterWriteUint32Field(PBDataWriter* writer, uint32_t value, uint32_t tag);
51  void PBDataWriterWriteUint64Field(PBDataWriter* writer, uint64_t value, uint32_t tag);
52  
53  // not entirely sure about that second parameter type
54  void PBDataWriterWriteSubmessage(PBDataWriter* writer, PBCodable* codable, uint32_t tag);