structure

C same structure different size

谁都会走 提交于 2019-12-07 12:27:20
问题 My question is related to this one : c define arrays in struct with different sizes However, I do NOT want to use dynamic allocation (embedded target). Problem recap : In C , I want to have two versions of the same structure, each one with a different size for its static arrays. Both the structures will be used by the same functions through pointer parameter. typedef struct { short isLarge; //set 0 at initialization short array[SIZE_A]; //more arrays } doc_t; typedef struct { short isLarge; /

protocol buffers: how to serialize and deserialize multiple messages into a file (c++)?

女生的网名这么多〃 提交于 2019-12-07 11:03:31
问题 I am new to Protocol Buffers and c++ but my task requires me to use the two. I want to write a structure of data ( message) into a single file multiple times and be able to read the data. i can read and write a single message but multiple messages is proving harder. I have looked for answers for hours but i can't seem to be able to read the data as a structure. Any example code or pointers will be very helpful. This is the format of my structure: typedef struct Entry { char name[ NAME_MAX];

Marshalling a C# structure

冷暖自知 提交于 2019-12-07 09:18:27
I am trying to serialize the following c# structure: [Serializable] [StructLayout(LayoutKind.Sequential, Size = 70, CharSet = CharSet.Ansi)] public struct USSDContinueModel { [MarshalAs(UnmanagedType.U4)] public uint Command_Length; [MarshalAs(UnmanagedType.U4)] public uint Command_ID; [MarshalAs(UnmanagedType.U4)] public uint Command_Status; [MarshalAs(UnmanagedType.U4)] public uint Sender_ID; [MarshalAs(UnmanagedType.U4)] public uint Receiver_ID; [MarshalAs(UnmanagedType.U1)] public uint Ussd_Version; [MarshalAs(UnmanagedType.U1)] public uint Ussd_Op_Type; [MarshalAs(UnmanagedType.ByValTStr,

How to Store and Fetch Json Model data to Coredata in Swift

久未见 提交于 2019-12-07 07:59:27
I have used coredata long back. But, I know basics of coredata for storing data and fetching. But, Presently I am working with Swift language. I have local json file and I am doing parsing that by decoder and displaying that data in tableview. let path = Bundle.main.path(forResource: "file", ofType: "json") do { let data = try Data(contentsOf: URL(fileURLWithPath: path ?? ""), options: .mappedIfSafe) let decoder = JSONDecoder() do { quData = try decoder.decode(quData.self, from: data) DispatchQueue.main.async { self.myTableView.reloadData() } } catch { print("Json decoder error") } } catch {

accessing member of structure within a class

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 07:19:19
问题 I have an .hpp and .cpp file. I want to access the variable in the structure within a class which happens to be in the header .hpp file, in the .cpp file. In .hpp, I have class foo{ public: struct packet{ int x; u_int y; }; }; foo(const char*name) :m_name(name){} In .cpp I did: foo *foo_1 = &foo; printf("The value of x is : %d",foo_1->packet.x); printf ("The value of y is : %u", foo_1->packet.y); On doing this I receive the following error: code_1.cpp:117: error: expected primary-expression

How to sort a structure array

情到浓时终转凉″ 提交于 2019-12-07 06:02:47
问题 How do I sort the oo structure array alphabetical order by item name. oo = struct('Item', {'Quill','Ink Pen', 'Pencil'}, 'Cost', {10, 2, 1}) I tried using the sort() function but it didn't work? Thank you. 回答1: First index your field, in this case oo.Items which returns a comma separated list. For string data use {} to concatenate to a cell of strings, otherwise use [] to get an array: %get the right order using second output of sort [~,index]=sort({oo.Item}) %sort it oo=oo(index) 来源: https:/

How do I structure my PHP project?

▼魔方 西西 提交于 2019-12-07 03:16:19
问题 I am about to embark upon yet another large PHP project. This time, I intend to have the project folder be tidy! So I have a few questions concerning keeping my project clean and DRY: How do I differentiate between PHP source files and PHP files that should be accessed by the browser? In other words, how do I make it clear which PHP files gives output and which gives function or class definitions? I am planning on separating my PHP functions into static classes, separated by subject, for

How to set up Umbraco to default in a subpage?

雨燕双飞 提交于 2019-12-07 01:42:35
问题 I have this question about umbraco structuring and I can't find the answer anywhere. Typically in Umbraco it will default the root site to the first node of the tree. so if we have Home page 1 page 2 the default page will be home (so www.mysite.com will point to home). How do I change this however so that www.mysite.com will point to page1 or page2? What if I have this structure? wrapper index page 1 page 2 and I want www.mysite.com to go straight to www.mysite.com/index.aspx I couldn't find

How to get table structure in CodeIgniter

放肆的年华 提交于 2019-12-07 01:26:05
问题 I want to know the structure of a table. How I can do it in CodeIgniter. Using database class I got 'Invalid SQL Statement' error when I ran $this->db->query('desc mytable'); 回答1: Try: $fields = $this->db->list_fields('table_name'); foreach ($fields as $field) { echo $field; } From manual 回答2: For more descriptive information, you should use $fields = $this->db->field_data('table_name'); You're going to get something like this foreach field in fields as stdClass name = "id" type = "int" max

Component without template

旧时模样 提交于 2019-12-06 17:45:25
问题 I have a bit of code that makes an api call to a server and returns some JSON. It did exist as a method in my component but as it is getting a bit long I want to extract it to it's own file In vuejs what is the best practice here. should it be a component without a template? How would this work? will I just create an es6 module? 回答1: I would suggest using a mixin here. In a file like myCoolMixin.js define your mixin... export default { methods: { myAwesomMethod() { //do something cool... } }