Questions tagged [user-defined]

253 questions
4
votes
2 answers

What is the point of using user defined Scanner class to read data in Java?

This code is from a competition, it works just fine if I use the built-in Scanner class to read data. But here, in this original solution, they defined a custom class MyScanner to read data? Why is that? Does it has anything to do with the execution…
Shakil
  • 585
  • 5
  • 17
4
votes
4 answers

No compilation error when the "same" user-defined conversion exists twice

In C#, why are there no compilation errors when the "same" user-defined conversion exists twice? (once in the source class and once in the target class?) For example, if I try to compile the following code I get no compilation errors: namespace…
4
votes
3 answers

where should I put the specialized std::hash for user defined type

I searched many pages, and I think I have known how to write the std::hash. But I don't know where to put it. An example is presented here http://en.cppreference.com/w/cpp/utility/hash . However, I defined my type Instance in namespace ca in file…
John Smith
  • 201
  • 2
  • 12
4
votes
1 answer

User-defined execption with custom message

Want to define a custom message for a user defined exception. What I have now: declare e exception; pragma exception_init (e, -20100); begin raise e; end; ORA-20100: ORA-06512: at line 5 What I want: exec…
Nick Legend
  • 789
  • 1
  • 7
  • 21
4
votes
1 answer

Unix sort text file with user-defined newline character

I have a plain text file where newline character in not "\n" but a special character. Now I want to sort this file. Is there a direct way to specify custom new-line character while using unix sort command? I don't want to use a script for this as…
AnonGeek
  • 7,408
  • 11
  • 39
  • 55
4
votes
2 answers

Java: Generate Random Numbers following a user defined Function

Thanks in advance for any help. I need to create random numbers which follow a user defined function in Java. The general way of doing this is through applying an uniform distribution to the integral of the function. The thing is that I need to…
beethovenj
  • 41
  • 3
3
votes
1 answer

mysql user-defined variable concurrency in connection pool?

In mysql we use @ for user-defined variable, which stays alive until the connection is closed. In java, when multiple threads share one connection pool, while calling a stored procedure concurrently to get rankings: BEGIN SET @rank := 0; SELECT…
Lee
  • 103
  • 1
  • 11
3
votes
3 answers

What is the best way to model user defined hierarchical relationships in a database?

Essentially, I want the user to be able to define a hierarchical model, but then I need to allow the user to store data within their defined model. Does this make sense? So the users will be able to create new "unit types" to be organised in a…
ninesided
  • 23,085
  • 14
  • 83
  • 107
3
votes
2 answers

DDD – How to implement validation against database

I'm struggling with a basic issue. The project is in C#, but the issue is general. I'm following the always valid object principle. As one example I have a product entity that has a mandatory property "ProductCategory". The allowed product…
3
votes
2 answers

User-defined routine in Doctrine 1.2?

I have to write an user-defined routine for my MySQL database (calculating distance function). Is it possible to define it in yaml schema file? After defining routine in terminal mysql-client everything is ok until 'doctrine build-all-reload' -…
Tomasz Rozmus
  • 1,646
  • 13
  • 21
3
votes
1 answer

use user defined function after grouped data in R

I have a function checking zero numbers in each column in a large dataframe. Now I want to check zero numbers in each col after grouped by category. Here is the example: zero_rate <- function(df) { z_rate_list <- sapply(df, function(x)…
newleaf
  • 2,257
  • 8
  • 32
  • 52
3
votes
2 answers

Python user-defined exceptions to handle specific OSError codes

I want to handle specific OSError codes like this: try: os.scandir() except OSPermissionError as error: # Only catch errno.EACCES, errno.EPERM handle_permission_error() except OSFileNotFoundError as error: # Only catch…
Buoy
  • 795
  • 1
  • 8
  • 13
3
votes
1 answer

Highlighting lines starting with #IF... using User Defined Language in Notepad++

I want to use syntax highlighting in Notepad++ for a script language that I'm working with. I set up keywords and stuff in "User Defined Language" and pretty much everything works as I'd like it to except for the following: The script language uses…
Nassbirne
  • 135
  • 1
  • 8
3
votes
1 answer

Inherit all functions from user-defined iterator in reverse_iterator

I am writing a JSON class for C++11, see http://github.com/nlohmann/json. My central data structure is a class wrapping the JSON value types (null, array, object, string, bool, number) in a union and offering it in via a nice C++ interface. As…
Niels Lohmann
  • 2,054
  • 1
  • 24
  • 49
3
votes
4 answers

User defined conversion operator as argument for printf

I have a class that defined a user defined operator for a TCHAR*, like so CMyClass::operator const TCHAR*() const { // returns text as const TCHAR* } I want to be able to do something like CMyClass myClass; _tprintf(_T("%s"), myClass); or…
BC.
  • 33
  • 3
1 2
3
16 17