Questions tagged [construct]

Construct is a powerful declarative parser for binary data.

It is based on the concept of defining data structures in a declarative manner, rather than procedural code: Simple constructs can be combined hierarchically to form increasingly complex data structures. It's the first library that makes parsing fun, instead of the usual headache it is today. Official documentation: https://construct.readthedocs.io

239 questions
0
votes
1 answer

How to initialize a ID value in constructor class and get the las ID autoincrement in doctrine, symfony2?

I have a class with field ID autoincrement class Prueba{ /** * @var integer $id * * @ORM\Column(name="`id`", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; but when I try this: public function…
Alex
  • 93
  • 1
  • 1
  • 5
0
votes
1 answer

Create and return a vector of strings - most efficient solution?

In a member function, I want to return a newly created vector of strings. Which version is the most efficient from a memory allocation & constructor calling point of view? theString(i) returns a const std::string & std::vector
galinette
  • 8,896
  • 2
  • 36
  • 87
0
votes
0 answers

Undefined Variable in __ construct

When i try to define a variable in __construct it still gives me an error of an undefined varbile. could you help?
Jamie Harding
  • 31
  • 1
  • 6
0
votes
1 answer

Matlab Convert structure refrence and values to variables

I've been searching for about a day for this but couldn't find an answer for it. What i want to do is to change this construct (solution of solve function): Fx3: [1x1 sym] Fy3: [1x1 sym] Fyp3: [1x1 sym] u2: [1x1 sym] u3: [1x1 sym] up3: [1x1…
Babak DS
  • 113
  • 6
0
votes
2 answers

Create properties in a class with the names and values of all the variables passed to the constructor

I want to create properties in a class with the names of all of the variables passed to the constructor and with the same values. I was able to do it with strings: class test { public function __construct() { $args = func_get_args(); …
James
  • 261
  • 2
  • 5
  • 16
0
votes
2 answers

Why throws 'Caught Exceptionn' instead of 'Caught MyExceptionn' although I have the construct of the class?

I have this code: class MyException extends Exception {} function __construct($palabra){ echo 'hola.adios'; } try { throw new MyException('Oops!'); }catch (Exception $e) { echo "Caught Exceptionn"; }catch (MyException $e) { echo "Caught…
dapaez
  • 1
  • 2
0
votes
2 answers

Add CRC field using Construct python library

I have the following simple protocol frame. For testing I've been assuming a fixed CRC field, but now I need to add the actual CRC computed from the previous bytes in the frame. How to do it? Maybe by nesting structs? MyFrame = Struct("MyFrame", …
0
votes
1 answer

mysqli_connect return to private var

someone could help me understand why __construct() is not working as expected? Or why $link is being Undefined? I got error: Notice: Undefined variable: link in D:\wamp\www\OI_WORK\forms\Projeto_Interface\ONGOING\php\class.php on line 29 This is…
0
votes
6 answers

How to construct a String without duplicate characters?

I am working on a personal project in Java and I am trying to build really fast a String without duplicates. Let me give you a specific example: String s = null; for (char c : tableChars) { s += c; } Ok, so I know that I can check if this…
user2435860
  • 778
  • 3
  • 9
  • 22
0
votes
3 answers

Undefined variable notice in __construct

Im getting an error at the class' __construct, says: Notice: Undefined variable: DEFAULT_TOP_PAGE_ID in classes.php on line XY. Here is the code: // consts.php
tcxbalage
  • 696
  • 1
  • 10
  • 30
0
votes
2 answers

why use construct function in php4 or php 5?

Here is some code. I took it from php anthology part1 . It's php 4 code so construct function using the class name. To experiment I remove construct function and yet it returned same result. So why do I use construct function if I get same result…
rushdi
  • 221
  • 1
  • 2
  • 14
0
votes
2 answers

PDO __constructs expects at least 1 parameter, 0 given

I have database class and constructor function this:
user2812532
  • 73
  • 2
  • 10
0
votes
1 answer

Construct function addPage cuts everything after first letter in foreach

I am working on a new UI class and i have stumbled upon a wierd issue where the script cuts off everything after the first letter. Let me show you my code. class UI { // legger CSS-fil til public function addCSS($css_file) { …
Dan-Levi Tømta
  • 796
  • 3
  • 14
  • 29
0
votes
5 answers

How to place a function inside a __construct() in PHP

I would like to create an object, but i'm a beginner at OOP, tried the code below and it returns the error code: Parse error: syntax error, unexpected '(', expecting '&' or variable (T_VARIABLE) in…
Alexandrw
  • 1,289
  • 2
  • 8
  • 10
0
votes
1 answer

In python construct library (for parsing binary data), how to group the rest of data as one field?

I am using Python construct library to parse Bluetooth protocols. The link of the library is here As the protocols are really complex, I subdivided the parsing into multiple stages instead of building one giganic construct. Right now I already parse…
foresightyj
  • 2,006
  • 2
  • 26
  • 40