yolobs-studio/libobs/util/dstr.hpp

47 lines
1.4 KiB
C++
Raw Normal View History

2016-02-23 23:16:51 +00:00
/*
* Copyright (c) 2014 Hugh Bailey <obs.jim@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "dstr.h"
class DStr {
dstr str;
2019-09-22 21:19:10 +00:00
DStr(DStr const &) = delete;
DStr &operator=(DStr const &) = delete;
2016-02-23 23:16:51 +00:00
public:
2019-09-22 21:19:10 +00:00
inline DStr() { dstr_init(&str); }
inline DStr(DStr &&other) : DStr() { dstr_move(&str, &other.str); }
2016-02-23 23:16:51 +00:00
inline DStr &operator=(DStr &&other)
{
dstr_move(&str, &other.str);
return *this;
}
2019-09-22 21:19:10 +00:00
inline ~DStr() { dstr_free(&str); }
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
inline operator dstr *() { return &str; }
inline operator const dstr *() const { return &str; }
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
inline operator char *() { return str.array; }
inline operator const char *() const { return str.array; }
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
inline dstr *operator->() { return &str; }
2016-02-23 23:16:51 +00:00
};