MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / FieldModelBalance

Class FieldModelBalance

projects/Python/proto/proto.py:1210–1394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1208
1209
1210class FieldModelBalance(fbe.FieldModel):
1211 __slots__ = "_currency", "_amount",
1212
1213 def __init__(self, buffer, offset):
1214 super().__init__(buffer, offset)
1215 self._currency = fbe.FieldModelString(buffer, 4 + 4)
1216 self._amount = fbe.FieldModelDouble(buffer, self._currency.fbe_offset + self._currency.fbe_size)
1217
1218 @property
1219 def currency(self):
1220 return self._currency
1221
1222 @property
1223 def amount(self):
1224 return self._amount
1225
1226 # Get the field size
1227 @property
1228 def fbe_size(self):
1229 return 4
1230
1231 # Get the field body size
1232 @property
1233 def fbe_body(self):
1234 fbe_result = 4 + 4 \
1235 + self.currency.fbe_size \
1236 + self.amount.fbe_size \
1237
1238 return fbe_result
1239
1240 # Get the field extra size
1241 @property
1242 def fbe_extra(self):
1243 if (self._buffer.offset + self.fbe_offset + self.fbe_size) > self._buffer.size:
1244 return 0
1245
1246 fbe_struct_offset = self.read_uint32(self.fbe_offset)
1247 if (fbe_struct_offset == 0) or ((self._buffer.offset + fbe_struct_offset + 4) > self._buffer.size):
1248 return 0
1249
1250 self._buffer.shift(fbe_struct_offset)
1251
1252 fbe_result = self.fbe_body \
1253 + self.currency.fbe_extra \
1254 + self.amount.fbe_extra \
1255
1256 self._buffer.unshift(fbe_struct_offset)
1257
1258 return fbe_result
1259
1260 # Get the field type
1261 @property
1262 def fbe_type(self):
1263 return self.TYPE
1264
1265 TYPE = 2
1266
1267 # Check if the struct value is valid

Callers 3

__init__Method · 0.70
__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected