The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [wrapper]

A wrapper is an OOP technique where an object encapsulates (wraps) another object, hiding/protecting the object and controlling all access to it.

Filter by
Sorted by
Tagged with
15
votes
1answer
500 views

Event-based Xbox Controller polling

The goal of the following code is to be able to use an Xbox Controller in a Java program, it works with the jinput library. Unfortunately this library is rather old, has little to no documentation ...
12
votes
2answers
400 views

Data marshaling wrapper for a TCP server

After a lot of research, I created this wrapper which I think fits very well to my needs. My project is a TCP server and I will be using this wrapper every time the server receives a packet. Basically,...
11
votes
2answers
3k views

Async wrapper around public API

Tear it apart. I'm mostly concerned around the appropriate use of ConfigureAwait(false), and possible poor handling and duplication of the ...
11
votes
1answer
572 views

Set of wrapper functions for POSIX signal APIs on Linux

Please feel free to comment on the accuracy/validity of the following wrapper source for processing signals using the new POSIX sigaction API. If you feel I'm doing anything wrong or potentially ...
10
votes
1answer
367 views

Correct usage of alignas in std::ostringstream wrapper

Please take a look at this code: ...
9
votes
2answers
553 views

Proxy/Wrapper class for a dynamic object from a SOAP API

I have to interface with a horrible PHP SOAP API that returns nested arrays of strings. I've written a helper that can parse the SOAP response and return a dynamic object but I need at least some ...
8
votes
1answer
4k views

Concurrent HashSet

I've recently been using HashSet and locking on each method, I found this to not only be a lot of work (was using it in a lot of places) but I started to see inconsistency in my code. I later decided ...
8
votes
3answers
888 views

Wrapping COM objects with IDisposable

One of the things believed to contribute to destabilizing Rubberduck 2.x, is the fact that a lot of COM object references are stored in many places, and ...
8
votes
3answers
213 views

Executable wrapper around Perl script on Windows

I have ack (the searching tool) "installed" as a single file at C:\ack\bin\ack.pl on a Windows 10 machine and was wondering how to make it executable from the ...
8
votes
1answer
1k views

Wrapping libusb library in C++

I want to use libusb library in my C++ application. I have created classes which wraps libusb functions. You can see that libusb API is split into 8 sections: http://libusb.sourceforge.net/api-1.0/...
8
votes
1answer
317 views

Wrapper around Python's poplib.POP3 and poplib.POP3_SSL

From time to time I use Python's poplib module to inspect/manipulate POP3 mailboxes, often interactively. I find the interface very cumbersome however, so I decided to try to make a wrapper that's ...
7
votes
2answers
13k views

Wrapping tuples to be used as keys in a Dictionary

I'm currently working on a project where I have to map some objects to several properties. Basically I need a Dictionary with Tuples as keys and instances of MyClass as values. As using tuples can ...
7
votes
2answers
550 views

Scala BitSet implemented with Java BitSet, for use in Scala Enumerations to replace ValueSet

Due to a performance profiling hotspot detailed here, I implemented my own BitSet using Java's BitSet. This is intended to ...
7
votes
1answer
3k views

Primitive Type Wrapper in C++

In C++, primitive types are treated differently than user-defined types. If you do not initialize them, their values are undefined in some cases. This is an easy mistake to make. I wanted to make a ...
7
votes
1answer
2k views

OpenGL object wrapped in a Qt Widget

I have this object wrapper class, which I will use to implement my Qt OpenGL scene. It is working, but I am looking for a way to: Improve the API. Remove extra OpenGL calls. Optimize it. I know that ...
7
votes
1answer
182 views

Linux/Mac hashing SHA-1

To do password exchange on the SQL server I need to use SHA-1 to generate a hash (no plain password exchange). This is done differently on Linux/Mac so I abstracted it slightly. ThorCryptWrapper.h <...
6
votes
2answers
716 views

Critique of realloc() wrapper

Seeking code correctness and best practices. I would like to re-allocate various amounts of memory (0 or more) such that on systems that may return NULL for an ...
6
votes
2answers
119 views

MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are: Would you create the module different? Do ...
6
votes
1answer
165 views

Random generator extension for VSCode

Background A VSCode extension that uses Chance.JS to generate random data types. Concerns My main concern is that there are 4 levels of function references that feels like a hack. From ...
6
votes
1answer
403 views

Debug log wrapper

I will be adding functionality and most likely additional refactoring, however a stringent review would be welcome before I build it further. I know documentation is probably a bit sparse but, you ...
5
votes
2answers
6k views

Basic API wrapper around a Restful service

I'm writing a basic wrapper around a restful service that returns a list of Stores. I'm using RestSharp which I'm injecting into the class. Naturally, I want to make it completely testable (that's a ...
5
votes
2answers
1k views

C array wrapper

As part of a larger project I wanted to write my own size once RAII C array wrapper. Now I could have just used std::vector, which I'm sure is the first thing ...
5
votes
2answers
865 views

Wrapper class for PHPMailer

Is this a right way to use/implement an external library into a project? If it's not how do you do it? ...
5
votes
2answers
118 views

Wrapper for Python's argparse class

I'm just trying to learn python: I tend to write my own customized wrappers arround "more complicated" python functionalities so that i can use them more easily, more consistent, easier to change in ...
5
votes
2answers
2k views

C++/CLI wrapper around a C library

I have a C library written by a third-party company. It calculates photo positions on a book page, position of a photo inside an area (which part of the photo to crop), it fills a book with random ...
5
votes
2answers
5k views

Wrapper around default shared preferences in Android

Retrieving an instance of (Default) SharedPreferences and then calling the six methods that may be called to put/get a value gets pretty old pretty quickly, so I ...
5
votes
2answers
99 views

Automatic RAII wrapper for concurrent access

Probably many people had to work with multithreaded applications with C++ and can understand how messy can be fine-grained locking of objects. So once in a while I came to idea of implementing some ...
5
votes
1answer
31 views

Short header file for safe CLI input handling in C

Proper input handling is a pain in the butt in C, so as part of a project of mine, this header is used to handle reoccurring command line input tasks such as input loops, reading lines and tokenizing ...
5
votes
1answer
217 views

Wrapper class for the shell “dir” utility

I was inspired to throw this class together by an SO question and thought I'd subject it to some welcome criticism here. The class is basically just a wrapper around the shell utility ...
5
votes
1answer
369 views

Python wrapper for official Hacker News API

Since Hacker News launched their official API, I started working on Python wrapper for it. API v0 is fairly simple, you send a GET request with hacker news story's ID or user id, it returns data in ...
5
votes
1answer
5k views

C++ syslog wrapper

Some things I want to achieve with the logging code. Code is for an embedded device. Code must only work for Linux. C++11 can be used. Syslog daemon is running on the device. So I want to wrap syslog....
5
votes
1answer
1k views

An iterator wrapper that on dereferencing, returns the value of a member (function)

I wrote a simple iterator wrapper that can be used in e.g. std::find and std::copy and iterator pair constructors to search on ...
5
votes
1answer
69 views

`ls` indicates when directory is empty/full of dotfiles

I want ls to print a message when run on an empty or full of dotfiles directory. Instead of: $ ls empty_dir/ dotfiles/ $ I ...
5
votes
1answer
275 views

Python wrapper for Instagram API

This code wraps the user endpoint and media endpoint of Instagram API. Any best practices/ styles or glaring bugs you can see? I wrote some unit tests for each class but did not include for ...
5
votes
0answers
31 views

Python wrapper to PSUtil

The class below provides a set of utility methods to currently running process. It is a wrapper around Python PSUtil to check status of a process in localhost as well as remote host. Please help me ...
4
votes
2answers
88 views

F# wrapper to generate SHA256 signature for a file

I've created the following module to allow me to generate a SHA256 signature for a file. (In real life this is used to verify an image file hasn't been amended). The cut down code looks like this: <...
4
votes
2answers
3k views

C++ Wrapper for cURL: Multithreading and serializing asynchronous ops

I did this library to help me from one of my projects and decided to publish it on GitHub hoping people might find it useful, convenient and easy to use in their projects too. It's a header-only ...
4
votes
2answers
57 views

Generic wrapper for single value or array of values

I'm writing a chart.js port for c# blazor (you can find it here) using C# 8.0 with .NET Core 3 (latest preview). In chart.js there is this thing called indexable options. It let's you use either a ...
4
votes
2answers
110 views

Automatic exception wrapper in java

There's a lot of place in my code where I need to do something like this ...
4
votes
1answer
935 views

Window Creation Wrapper Class

This Question now has a follow-up here I don't think that there is any new technique in my code but in my opinion it's ok all in all (with a bit of magic). Maybe you can find something to improve or ...
4
votes
1answer
298 views

Angular wrapper for SignalR event aggregator

I created a little wrapper for one of my JavaScript libraries to enable Angular functionality. Are there any pitfalls I should be wary of with my code? ...
4
votes
1answer
1k views

PHP wrapper around an API - best practices

Here's a PHP wrapper around a public OAuth2 REST API. I would love to hear your thoughts and comments. Testing was a bit frustrating since I tried for my first time. Not sure if I have done the ...
4
votes
1answer
44 views

C++ wrapper around uniform mt19937 SequenceContainer [closed]

With the following interface in mind EasyRandom<unsigned int> prng(a, b); auto x = prng(); // scalar auto v = prng(10); // vector I wrote the following ...
4
votes
1answer
5k views

PHP MySQLi wrapper class

I've created a minimal PHP-MySQLi database wrapper class that can be used to run insert, select, update and delete queries via prepared methods with ease. Here's the wrapper class: ...
4
votes
1answer
72 views

Thin proxy class for hashables

I need some kind of thin wrapper object to mark dictionary keys, like: d = { Required('name'): str, Optional('age'): int, } And these wrappers should behave ...
4
votes
1answer
1k views

Simple C++ wrapper over libYAML

For a personal project, I need to parse YAML file. I chose to use C-based libYAML instead of yaml-cpp, because: I try to keep my dependencies to what's commonly installed and Debian statistics show ...
4
votes
1answer
2k views

C++ lock wrapper class around pointer

I have created a class which wraps pointers and behaves like a pointer would behave, minus a few cases. It is a lock wrapper class which simply locks before usage of the pointer and unlocks once the ...
4
votes
1answer
120 views

Wrapping a non-unique handle with additional information

I have a situation where I'd like to wrap up some plain C handles into a class, with a destructor and other niceties, in C++. I would like the wrapper class to have the exact same size as the handle, ...
4
votes
2answers
519 views

Encryption wrapper

I am writing an encryption class using Crypto++. The idea is that the client connects using RSA (encrypt, decrypt) with username, password, 32 byte key. The server will then return using the stream ...
4
votes
1answer
737 views

Wrapper library for Google Static Maps API

I've recently read the books Clean Code and Effective Java. I am a huge fan of Object-Oriented Java. I am trying to write as professionally as possible. I have been an Android Developer for 20 months ...