structure

Application structure using WCF

I have a WPF application which so far has been client only, but now I'm working on splitting it into a client and server side. In this work I'm introducing WCF for the client-server communication. My application has several projects, and service references are needed from more than one of these. Initial effort in doing the separation i...

Using struct causes kernel panic?

I'm taking my first crack at writing some linux kernel code, and I'm hitting a weird kernel panic. I have a linked list I am maintaining with the kernel's built-in macros (include/linux/list.h). If the list is empty, I allocate an instance of the following structure: struct time_span { struct timeval start; struct timeval end; };...

How do I over-allocate memory using new to allocate variables within a struct?

So I have a couple of structs... struct myBaseStruct { }; struct myDerivedStruct : public myBaseStruct { int a, b, c, d; unsigned char* ident; }; myDerivedStruct* pNewStruct; ...and I want to dynamically allocate enough space so that I can 'memcpy' in some data, including a zero-terminated string. The size of the base struct...

Difference between Class and Structure in PHP and Java

What is real difference between Class and Structure when you are dealing with Object Oriented Programming. This question is asked many times during my interviews for SE. Some people says that there is only one difference: Structure members are public by default and Class members are private by default. Some says there are many differen...

Is this valid XML?

I know that syntax is valid, but my question is whether it is logically valid: <parent> <name>John</name> <child>Mary</child> <child>Lucy</child> <child>Hannah</child> </parent> or a proper way to do this is: <parent> <name>John</name> <child> <name>Mary</name> </child> <child> <name>Lu...

typecasting bigger or smaller structure in C

I have two structures in C program: SmallStructABC and BigStructXYZ I have several members in both of them; SmallStructABC's all 10 members are exactly same as first 10 members of BigStructXYZ. BigStructXYZ has 50 additional members. Is it OK to type-cast this two structures to each other? SmallStructABC *i = (BigStructXYZ*)j; BigStr...

C# P/Invoke: Marshalling structures containing function pointers

Sorry for the verbose introduction that follows. I need insight from someone knowing P/Invoke internals better than I do. Here is how I'm marshalling structures containing function pointers from C to C#. I would like to know whether it's the cleanest and/or most efficient way of doing it. I'm interfacing with a native DLL coded in C th...

Rich tree structures with PHP

I'm finding it very difficult to find anything about creating maintanable, navigatable and verbose tree structures in PHP. I wanted to open it up to the SO community and see who's done what. The way I can see creating this sort of structure is to have an object for every node, with a reference to the parent or child nodes. I've yet to p...

Code infrastructure for accessing different properties of multiple elements (vector graphics editor)

Hi everybody, I am currently working on a small vector graphics editor (sort of) and facing a code design question, wondering how it would be solved in an elegant and straightforward manner. If anyone has a good idea how to solve this, or knows a good link or a piece of open source code dealing with a similar setup, I would be really ...

Structurally and visually organising DBs and tables in SSMS

Hi Within the next few weeks I plan to introduce SQL server to an office that is in dire need of a proper data server. Currently there is a heavy reliance on loose Excel and Access file (supplemented with frighteningly large amount of impenetrable VB code to do data manipulations) strewn all over the internal network. We need SQL serve...

What are the methods available in storing sequential files?

I have certain doubts about how the sequential files are stored and I would like to know about it. ...

AddInOrder Best Structure? Java homework

Hi Currently I have a problem where I have a list of IDs, each with a related score. For example: ID : SCORE 1 : 12 2 : 15 3 : 2 4 : 99 I want to loop over these and add them to a structure in decending order of score. So the output will look something like {4,2,1,3} What is the best way of doing this in Java? A queue? Thanks ...

SQL table - semi-unique row?

Hi I have an SQL table with basically the following structure: PK (int, primary key), userID (int), data (varchar 64) Basically, any user as defined by userID is allowed to store any number of short strings. However, no user is allowed to store two identical strings (although user 1 and user 2 can both store the same string separatel...

Creating a Structure from a string in C#

I've seen a lot of questions asked about instantiating classes from a string but have been unable to find any information on creating a structure the same way. I have a class which contains a structure like so: Public Structure callDetails Public GUID As Guid Public ringTime as Date Public CBN As String etc. All I really...

What's the best way to structure unit tests in solutions?

I'm working on a C# .net project using Visual Studio 2008, so my question is specifically for this case. However, the question should be the same to many other environments, so I'll be glad to hear opinions from people in similar environments. My solution is organized in several projects. All of which have some belonging unit tests. Th...

accessing Double pointer

typedef struct _WDF_USB_DEVICE_SELECT_CONFIG_PARAMS { ULONG Size; WdfUsbTargetDeviceSelectConfigType Type; union { struct { PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; PUSB_INTERFACE_DESCRIPTOR* InterfaceDescriptors; ULONG NumInterfaceDescriptors; } Descriptor; struct { PURB Urb; } Urb; struct { UCHAR Numb...

XSLT create nested structure (table of content-style) when there is none

This is what it looks like now <Titre_2>first level 01</Titre_2> <Titre_2>second level 01</Titre_2> <Titre_2>third level 01</Titre_2> <Titre_3_ch1>deepest01</Titre_3_ch1> <Titre_3_ch1>deepest02</Titre_3_ch1> <Titre_3_ch1>deepest03</Titre_3_ch1> <Titre_2>third level 02</Titre_2> <Titre_3_ch1>deepest04</Titre_3_ch1> <Titre_3_ch1>deepest05...

Accessing a structure variable double pointer

Some code: typedef struct _WDF_USB_DEVICE_SELECT_CONFIG_PARAMS { ULONG Size; WdfUsbTargetDeviceSelectConfigType Type; union { struct { PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; PUSB_INTERFACE_DESCRIPTOR* InterfaceDescriptors; ULONG NumInterfaceDescriptors; } Descriptor; struct { PUR...

Merging MySQL Structure and Data

I have a MySQL database running on a deployment machine which also contains data. Then I have another MySQL database which has evolved in terms of STRUCTURE + DATA for some time. I need a way to merge the changes (ONLY) for both structure and data to the DB in deployment machine without disturbing the existing data. Does anyone know of a...

Good way to create script supporting translations?

Hello I'm creating an open-source cms and was just wondering that which is the best way to add localizations? I already decided to have them in files similar to lang.en.php. I would assume arrays, but in which form? $lang['xyz'] = "Text goes here!"; $lang['Text goes here!'] = "Translated text!"; Or should I create my custom parser an...