Re: vibed how do I convert form values into a struct automatically?

2021-11-10 Thread Chris Bare via Digitalmars-d-learn
On Wednesday, 10 November 2021 at 19:23:44 UTC, Chris Bare wrote: What am I missing? I figured out part of it. In the html input element the name has to be employeeform.first_name. but now I get a different error: Error handling field 'employeeform.id': Missing form field. I tried declaring

vibed how do I convert form values into a struct automatically?

2021-11-10 Thread Chris Bare via Digitalmars-d-learn
I know I can do this manually by looking at HTTPServerRequest req, but the documentation for registerWebInterface sounds like there's an automatic way to do this. ``` required/> required/> ``` ```d struct Employee { long id; string first_name; @string last_name

Re: in a template, how can I get the parameter of a user defined attribute

2021-11-06 Thread Chris Bare via Digitalmars-d-learn
On Saturday, 6 November 2021 at 19:51:09 UTC, Adam Ruppe wrote: On Saturday, 6 November 2021 at 19:45:49 UTC, Chris Bare wrote: dbForeignKey!(Position) static if(is(T == dbForeignKey!Arg, Arg)) { // use Arg here } Thanks, that did it.

in a template, how can I get the parameter of a user defined attribute

2021-11-06 Thread Chris Bare via Digitalmars-d-learn
In the example below, one of the attributes is @dbForeignKey!Position. pragma (msg, attr) gives me: dbForeignKey!(Position). I want to be able to extract the Postion as a type so I can call another template like: save!Position (); Is this possible? ```d import std.stdio; import std.traits; im

Re: vibe.d json deserializeJson!Foo and ddbc.update!Foo

2021-02-13 Thread Chris Bare via Digitalmars-d-learn
On Saturday, 13 February 2021 at 01:21:56 UTC, Steven Schveighoffer wrote: On 2/12/21 6:22 PM, Chris Bare wrote: [...] Does @ignore work? That's a UDA that tells vibe to ignore the field. Though I don't know if it means it leaves it alone completely. https://vibed.org/api/vibe.data.seriali

vibe.d json deserializeJson!Foo and ddbc.update!Foo

2021-02-12 Thread Chris Bare via Digitalmars-d-learn
I'm working on a project with vibe.d and ddbc to access my database. Both have powerful functions that operate on Struct types to avoid a lot of boilerplate code. I have a web site that sends a json message to update a record. deserializeJson creates a new Foo record containing the json data. Ho

Associative Array Question

2020-12-31 Thread Chris Bare via Digitalmars-d-learn
I'm missing something about the way associative arrays are allocated. In the example below, case 1 and case 2 seem to be the same, a type indexed by a long. Case 2 fails with a Range violation. Can someone explain the difference? I found a work around (or the correct way) in case 3. struct Pro

How can I walk the list in a RegexMatch backwards?

2019-02-03 Thread Chris Bare via Digitalmars-d-learn
auto matches = matchAll(str, searchRegex); foreach (m; matches) // this walks the list forward I tried: foreach_reverse (m; matches) foreach (m; reverse (matches)) foreach (m; retro (matches)) and they all failed to compile. I also tried to index matches (matches[i]) but that does not work eit

Re: problem extracting data from GtkSourceView using Gtkd

2019-01-17 Thread Chris Bare via Digitalmars-d-learn
I think I finally figured it out. I think the GTKapplication shutdown signal is called after the window has been destroyed. If I attach a handler to the window's destroy signal, then I am able to get the data from the sourceView.

Re: problem extracting data from GtkSourceView using Gtkd

2019-01-16 Thread Chris Bare via Digitalmars-d-learn
Weird, the code does work in my program during startup, but when I call the same function from Application.onShutdown it gets the 0 results. Are the widgets destroyed before onShutdown? Here's a stripped down version my Application subclass: int main (string[] args) { auto applicatio

problem extracting data from GtkSourceView using Gtkd

2019-01-14 Thread Chris Bare via Digitalmars-d-learn
I would have posted this in the Gtkd forum, but it has been down for a while. I'm porting a GTK2/C program to Gtkd. I'm trying to read the data from a GtkSourceView, but when I try to get the bounds, it's always zero. Here's the c version that works: GtkSourceBuffer *bf; GtkT

Reading XDR data from a file

2018-11-24 Thread Chris Bare via Digitalmars-d-learn
I have a file in xdr format and I'm trying to use the xdr module from dub. After a lot of failures, I got this to work: ubyte[] b2 = cast (ubyte[]) read(fname); string n = cast (string) b2.get!string(); tracef("<%s>", n); I feel like there should be a way for the xdr get to read di

passing subclass to superclass where parameter is a delegate for the superclass

2018-11-14 Thread Chris Bare via Digitalmars-d-learn
If I have: class base { void delegate(base) stored_dg; void add_function (void delegate (base) dlg) { stored_dg = dlg; } } class A : base { this () { super (); add_function (&this.foo); } void foo (A a) { log ("i got here")